Code Room
CodingMediumcod-g847
Subject Sweep lineLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.