Falling Squares
Squares of given side lengths drop one at a time onto a number line at given left positions. Each square falls until it rests on the ground or on the top of a previously landed square that it overlaps horizontally. After each drop, report the height of the tallest stack so far. Return the list of these running maxima.
Open official problem prompt ↗After each falling square lands, know the height of the current tallest point across the whole line.
Stacking sticky notes on a wall: a new note sticks on top of whatever is highest in the horizontal strip it covers. You constantly report the highest note anywhere on the wall.
- Input
- positions = [[1,2],[2,3],[6,1]]
- Output
- [2,5,5]
- Why
- First square rests at height 2. The second overlaps it and stacks on top: 2+3=5. The third lands far away at height 1, so the tallest overall stays 5.
1 <= positions.length <= 10001 <= left, sideLength <= 10^8positions[i] = [left, sideLength]