Reported April 2024
Wayfairsimulation

Smash Bricks

Reported by candidates from Wayfair's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Wayfair OA. Under 2s to a working solution.
Founder's read

Wayfair's April OA included Smash Bricks, a simulation problem that looks deceptively simple until you realize the cascade logic will trip you up. You're given a grid of bricks, and when you remove one, others fall and potentially merge. The trick is handling the physics correctly without over-complicating your state tracking. StealthCoder reads the problem statement in real time and can walk you through the cascade rules if you blank on the sequence.

Pattern and pitfall

Smash Bricks is fundamentally a simulation problem where each move triggers a chain of gravity and collapse effects. The pattern: remove a brick at position X, apply gravity to bricks above it, detect horizontal merges of identical bricks, remove merged bricks, repeat gravity. Most candidates either miss the merge-then-gravity loop or implement gravity inefficiently. The core insight is that you need to iterate until no more merges occur, not just one pass. Use a 2D array to track brick states and write helper functions for gravity and merge detection separately. This keeps your code readable under time pressure. StealthCoder flags the cascade loop as the critical section if you get stuck mid-implementation.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Smash Bricks cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Wayfair's OA.

Wayfair reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Smash Bricks FAQ

What's the trick with brick merging?+

After gravity settles, scan for horizontal groups of 3+ identical bricks and mark them for removal. Then apply gravity again. The cascade continues until no more merges happen. Candidates often miss the "repeat until stable" part and only do one pass.

How do I handle gravity efficiently?+

For each column, compact non-zero bricks downward and fill empty space above with zeros. Don't manually shift each brick. Iterate top-to-bottom and fill from the bottom up. This is O(rows) per column.

Do I need to track the score for this OA?+

The problem likely asks for bricks removed or final grid state. Read the exact requirement carefully. Score tracking (if present) is usually just a counter incremented each time you remove a brick group.

What's the time complexity Wayfair expects?+

Each move triggers at most O(rows * cols) work per cascade iteration. With multiple moves, worst case is O(moves * rows^2 * cols), but optimized gravity and merge detection keep it tight for typical grid sizes.

Should I use recursion or iteration for the cascade?+

Iteration is safer. Use a while loop that repeats gravity and merge detection until the grid doesn't change. Recursion works but adds stack risk under time pressure. Keep it simple.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Wayfair.

OA at Wayfair?
Invisible during screen share
Get it