Minimum Obstacles To Remove To Allow Figure Fall
Learn this problemProblem statement
Note - See the problem source section below for the original prompt π°π°
10000 years agooooo, in the magical land of Gravity Falls, you found yourself playing a challenging puzzle game involving a mysterious, oddly-shaped figure that needed to fall gracefully to the bottom of a rectangular board. The board was made up of three types of enchanted cells: empty cells marked as '-', obstacles marked as '#', and the figure itself made of '*'. The figure was a single piece, with all of its parts connected by their sides, and it longed to touch the bottom of the board. Your quest was to help the figure descend by removing obstacles in its way, but only as many as absolutely necessary for it to finally touch the ground with at least one of its cells. The council of Gravity Falls understood that the task need not be approached in the most cunning way, but rather in a manner where you could explore every nook and cranny in at most board.length * board[0].length steps, solving the puzzle while uncovering the secrets of this gravity-bound world.
Function
minimumObstaclesToRemoveToAllowFigureFall(matrix: char[][]) β intExamples
Example 1
matrix = [["*","*","*"],["#","*","*"],["*","*","-"],["-","*","-"],["-","#","#"]]return = 2The figure needs to fall one row before one of its cells touches the bottom. During that movement it would collide with the obstacles at [1,0] and [4,1]. Removing those two obstacles is necessary and sufficient.
Constraints
ππ
More Meta problems
- Plan a Minimum-Cost Round TripONSITE INTERVIEW Β· Seen Jul 2026
- Merge Three Sorted ArraysPHONE SCREEN Β· Seen May 2026
- Highest Rating Price RatioOA Β· Seen Mar 2026
- Diagonal Traverse (for E4 ;)PHONE SCREEN Β· Seen Mar 2025
- Find Peak ElementPHONE SCREEN Β· Seen Mar 2025
- Find Pair Closest to K (for E5 :)PHONE SCREEN Β· Seen Feb 2025
- Get Minimum Round Trip Cost (: for E4 && E5 :)PHONE SCREEN Β· Seen Feb 2025
- Max Consecutive Ones III (for E5 :)PHONE SCREEN Β· Seen Feb 2025