Falling squares max height
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.
Implement
falling_squares(positions: list[list[int]]) → list[int]Examples
in
[[[1,2],[2,3],[6,1]]]out[2,5,5]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[[[1,2],[2,3],[6,1]]][2,5,5]not run yetsample