HARDasked at 2 companies

Bricks Falling When Hit

A hard-tier problem at 36% community acceptance, tagged with Array, Union Find, Matrix. Reported in interviews at Snap and 1 others.

Founder's read

Bricks Falling When Hit is a 2D matrix problem that shows up at Snap and Tower Research Capital. At first glance it looks like a straightforward simulation: remove bricks when they're hit, check what falls. The trick is you can't simulate forward in time. Instead you work backwards from the final state, adding bricks back one by one and tracking stability using union find. The 35% acceptance rate reflects how many candidates miss the reversal and get stuck in timeout or edge-case hell. If this lands on your OA and you freeze on the backwards approach, StealthCoder surfaces the working solution in seconds, invisible to the proctor.

Companies asking
2
Difficulty
HARD
Acceptance
36%

Companies that ask "Bricks Falling When Hit"

If this hits your live OA

Bricks Falling When Hit 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The problem gives you a 2D grid of bricks, a list of hits that destroy specific cells, and asks which bricks fall as a result. The naive approach is to simulate each hit, mark cells as empty, then BFS/DFS to find floating bricks. That fails because removing a brick doesn't instantly tell you which neighbors destabilize. The correct pattern is to reverse the input: start with all hit bricks missing, then add them back in reverse order of hits. Use union find to track which bricks are connected to the top edge (stable). When you add a brick back, check its four neighbors, union them if they're stable, and count how many newly-stable bricks that brick "catches". This reversal flips the problem from hard prediction into straightforward union find mechanics. Array, Union Find, and Matrix all appear in the topic list because you need matrix indexing, union find for connectivity, and array operations to track results.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Bricks Falling When Hit 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Bricks Falling When Hit interview FAQ

Why is working backwards the key to this problem?+

Forward simulation requires predicting cascading falls after each hit, which is hard to track. Reversing the problem lets you use union find to efficiently determine which bricks are stable (connected to the top). Adding a brick back and checking its neighbors is a single, deterministic operation. This transforms exponential complexity into linear union find cost.

Is this problem still asked at major companies?+

Yes. Snap and Tower Research Capital both ask it. At 35% acceptance, it's a strong filter for candidates who understand non-obvious algorithmic patterns. Most people who see it haven't encountered the backwards reversal trick before, which is why the acceptance stays low.

What's the most common mistake on Bricks Falling?+

Trying to simulate forward: remove a brick, then BFS to find what falls. This works for small inputs but times out and misses edge cases where removing one brick causes a chain reaction of instability. The reversal approach avoids the cascade problem entirely.

How do Union Find and Matrix topics connect here?+

Union Find is your stability tracking mechanism. Matrix skills matter because you need to navigate neighbors efficiently, handle 2D indexing without errors, and correctly map grid positions to union find sets. Both are fundamental to a clean implementation.

What preparation helps most for this problem?+

Drill union find on other problems first so the data structure is muscle memory. Then study problems where the algorithmic trick involves reversing the problem direction or processing input backwards. The reversal insight is rare; encountering similar patterns elsewhere builds intuition.

Want the actual problem statement? View "Bricks Falling When Hit" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.