Drop a Connected Figure Through Obstacles
Problem statement
A rectangular grid uses . for empty, # for obstacles, and F for one orthogonally connected rigid figure.
Move the complete figure downward as far as possible without any figure cell leaving the grid or overlapping an obstacle. Return the final grid.
Function
dropFigure(grid: String[]) → String[]Examples
Example 1
grid = [".F.",".F.","...",".#."]return = ["...",".F.",".F.",".#."]The figure falls one row before its lower cell would hit the obstacle.
Example 2
grid = ["F..","..."]return = ["...","F.."]The figure falls to the bottom.
Constraints
1 <= rows,columns <= 200