Reported October 2022
ZipRecruitersimulation

Pop Matching Balloon Neighborhoods

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

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

The input size on this ZipRecruiter OA, reported in October 2022, is what kills the lazy approach. The grid goes up to 200 by 200, so 40,000 cells, and you can't simulate pop after pop until nothing changes. It's one simultaneous round, then gravity. That's a matrix simulation problem dressed up as a game. If you read it slowly, it's a two-pass job. If you rush it, you'll mutate the grid mid-scan and get wrong answers. StealthCoder is the safety net if you blank during the live OA.

The problem

Positive integers are balloon colors and zero is empty. Evaluate one simultaneous popping round. A nonzero center triggers when at least two of its orthogonal neighbors have the same color; pop the center and every same-colored orthogonal neighbor of every triggering center.
After all pops, compact surviving balloons toward larger row indices within each column, preserving their order. Return the result.

Function
popBalloons(grid: int[][]) → int[][]

Examples
Example 1
grid = [[0,1,0],[1,1,1],[0,2,0]]
return = [[0,0,0],[0,0,0],[0,2,0]]
The center and its three matching neighbors pop before gravity.
Example 2
grid = [[1,1],[2,3]]
return = [[1,1],[2,3]]
One matching neighbor is insufficient.

Constraints
1 <= rows, columns <= 200
0 <= grid[r][c] <= 1000000000

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is separating detection from mutation. Pass one: for every nonzero cell, count orthogonal neighbors with the same color. If the count is 2 or more, it's a trigger. Mark the trigger and all its same-colored neighbors in a boolean grid. Don't change the grid yet, or later cells will see wrong neighbors. Pass two: for each column, walk from the bottom row up, copy unmarked nonzero values down into a write pointer, then fill the rest with zeros. That's O(rows x cols) total, which easily fits 40,000 cells. The common pitfall is only popping the center and forgetting its matching neighbors, or running multiple rounds. Example 1 shows the center and three neighbors all popping. Example 2 shows one matching neighbor isn't enough. If you freeze in the live OA, StealthCoder is the hedge that reads the problem and hands you the two-pass structure.

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 Pop Matching Balloon Neighborhoods 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 ZipRecruiter's OA.

ZipRecruiter 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.

Pop Matching Balloon Neighborhoods FAQ

What's the trick to Pop Matching Balloon Neighborhoods?+

Detect first, mutate later. Scan the original grid and mark every cell that should pop in a separate boolean array. Only after the full scan do you apply gravity. Mutating while scanning breaks the simultaneous rule and gives wrong neighbor counts.

How hard is this ZipRecruiter problem really?+

Easy to medium. No fancy algorithm is involved. The difficulty is reading the rules carefully: the trigger needs at least two matching neighbors, and matching neighbors of every trigger also pop. Most failures come from misreading, not from complexity.

What's the time complexity I should aim for?+

O(rows x cols). With a 200 by 200 grid, one detection pass checking four neighbors per cell, plus one gravity pass per column, is trivial. Anything that repeats rounds until stable is wrong and unnecessary here.

How do I handle gravity correctly?+

Work column by column. Start a write pointer at the bottom row, walk upward, and copy each surviving nonzero value to the write pointer, moving it up. Fill remaining top cells with zero. This preserves the order of survivors.

How do I prepare for this in 48 hours?+

Write the two-pass solution once from scratch and test both examples by hand. Practice a four-direction neighbor loop with bounds checks. Also test edge cases: a 1 by 1 grid, all zeros, and a full grid of one color.

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

OA at ZipRecruiter?
Invisible during screen share
Get it