Falling squares max height

Write codeMedium30 min

Your task

Squares fall one at a time onto a number line. Each is given as [left, sideLength]; it occupies the x-interval [left, left+sideLength) and falls until it rests either on the floor or on top of a previously-landed square it overlaps in x. After each square lands, record the height of the TALLEST stack anywhere on the line so far. Return that list of running maxima.

Examples

falling_squares(positions: list[list[int]]) -> list[int]
Example 1
Inputfalling_squares([[1, 2], [2, 3], [6, 1]])
Output[2, 5, 5]