Practice/Snowflake/Leetcode 1861. Rotating the Box
CodingOptional
You are given a 2D grid representing a box view from the side. The grid contains three types of elements:
'#' represents a movable block'*' represents a fixed obstacle'.' represents an empty spaceYour task is to:
Return the resulting grid after both transformations.
'#') downward'*') remain fixed and block falling blocks'.') allow blocks to fall through1 <= m, n <= 100 where m is the number of rows and n is the number of columns'#', '*', and '.'n × mExample 1:
` Input: grid = [['#', '.', '*'], ['.', '#', '.'], ['#', '#', '.']]
Output: [['.', '#', '#'], ['#', '.', '#'], ['*', '.', '.']]
Explanation: Step 1 - Original grid:
. # .
Step 2 - After 90° clockwise rotation:
. . *
Step 3 - After applying gravity (blocks fall down): . # #
Example 2:
` Input: grid = [['#', '#', '.', '.', '#']]
Output: [['.'], ['.'], ['#'], ['#'], ['#']]
Explanation: After rotation, all three blocks fall to the bottom. `
Example 3:
` Input: grid = [['#', '.', '#'], ['', '', '*'], ['#', '.', '.']]
Output: [['#', '', '#'], ['.', '', '.'], ['#', '*', '.']]
Explanation: The middle row of obstacles prevents blocks from falling through. `