Box Rotation Simulation
A box is an m x n matrix of numeric cells. A cell is 35 for a stone, 42 for a stationary obstacle, and 0 for an empty cell.
The box is rotated 90 degrees clockwise, so a source cell at row r, column c moves to row c, column m - 1 - r. After the rotation, gravity pulls every stone down as far as it can fall inside its column until it lands on an obstacle, another stone, or the bottom of the box. Obstacles do not move, and the rotation does not change a stone's horizontal position in the rotated frame. Return the final n x m matrix.
Examples
Input: [[35,0,42,0],[35,35,42,0]]
Output: [[35,0],[35,35],[42,42],[0,0]]
Input: [[35]]
Output: [[35]]
Hints
A clockwise rotation turns each input row into an output column, so settling each input row to the right and then rotating gives the same matrix as rotating and then settling downward.
Process each row from right to left and keep the rightmost free slot for the current obstacle-free segment.
An obstacle ends the current segment, so reset the free slot to the cell just left of the obstacle.
Related Problems
Box Rotation Simulation
A box is an `m x n` matrix of numeric cells. A cell is `35` for a stone, `42` for a stationary obstacle, and `0` for an empty cell.