Falling Squares
A hard-tier problem at 46% community acceptance, tagged with Array, Segment Tree, Ordered Set. Reported in interviews at Block and 0 others.
Falling Squares is a hard array problem that shows up in Block's interviews and stays low on acceptance rates for a reason. You're given a set of falling squares with positions and side lengths, and you need to calculate the height of the stack at each drop. The obvious approach, simulating each square's fall naively, times out immediately. The trick is recognizing this as a range-query problem where you need to track the maximum height across intervals as squares land. Most candidates either brute force and fail, or jump to segment trees without realizing an ordered set can solve it more elegantly. If this hits your live OA and you blank on the data structure strategy, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Falling Squares"
Falling Squares is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe core insight is that for each square, you're not just dropping it to a fixed position; you're querying the maximum height in a range, then updating that range. Segment trees handle this classically, but you can also use a coordinate-compressed ordered set with binary search. Most people try to simulate the physics step by step, which devolves into nested loops and O(n squared) or worse complexity. The real challenge is understanding why your brute force fails only after you've written it. Segment trees or balanced BSTs both work, but you need to recognize range-max-query and range-update patterns instantly. This is the kind of problem where StealthCoder becomes your safety net if the pattern doesn't click in the first two minutes of the live assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Falling Squares recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Falling Squares interview FAQ
Is Falling Squares really as hard as the rating suggests?+
Yes. The acceptance rate sits around 46%, which is genuinely low for a medium-plus problem and reflects the gap between understanding the physics and coding the right data structure. Most candidates waste time on simulation before realizing they need segment trees or ordered sets.
What makes the naive solution fail?+
Simulating each square drop by checking every previous square's position is O(n squared) or worse. With n up to a few hundred, that times out. You need to batch-query the maximum height across a range in sub-linear time.
Segment Tree vs. Ordered Set: which should I code?+
Ordered sets (TreeMap or equivalent) with coordinate compression are faster to code and less error-prone. Segment trees are more general but overkill here. Pick whichever you're faster with; both are O(n log n) and pass.
Is this problem asked often outside Block?+
Data is sparse; it's primarily documented at Block. But the pattern (range-max queries on a dynamic array) appears in cloud services and infrastructure interviews, so it's worth knowing even if you don't target Block specifically.
What's the coordinate compression trick everyone mentions?+
Your squares only matter at specific x-coordinates. Instead of a massive array, store only the intervals your squares occupy. This shrinks your data structure and makes segment trees or BSTs practical without blowing up memory.
Want the actual problem statement? View "Falling Squares" on LeetCode →