Reported September 2024
ZipRecruitersimulation

Pop Diagonal Bubbles with Gravity

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

This one looks like a bubble-popper, but it's really a grid simulation with a tiny rule set. ZipRecruiter reported it in September 2024, and the whole task reduces to two steps repeated per click: pop the cell plus its same-valued diagonal neighbors, then drop everything down each column. If your OA invite is for this week, the code is short once you stop overthinking it. StealthCoder is the safety net running invisibly during the live OA if your mind goes blank on the gravity step, but the logic below should be enough to write it yourself.

The problem

Zero is empty. For each [row,column], do nothing if empty; otherwise remove the selected bubble and every same-valued immediate diagonal neighbor.
After each removal, compact bubbles downward in every column while preserving vertical order. Return the final board.

Function
popDiagonalBubbles(board: int[][], operations: int[][]) → int[][]

Examples
Example 1
board = [[1,0,1],[0,1,0],[2,2,2]]
operations = [[1,1]]
return = [[0,0,0],[0,0,0],[2,2,2]]
The center and four diagonal 1s are removed; twos stay at the bottom.
Example 2
board = [[1],[0]]
operations = [[1,0]]
return = [[1],[0]]
Clicking empty does nothing.

Constraints
1 <= rows,columns,operations.length <= 200
Operation coordinates are in range.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that there's no flood fill. You only remove the clicked cell and its four immediate diagonal neighbors that match its value. No recursion, no BFS. Read the value first, check bounds, collect matching diagonals, then zero them all. Then apply gravity per column: scan from bottom to top, write non-zero values into a write pointer that starts at the last row, and fill the rest with zeros. The common pitfall is zeroing the clicked cell before reading its value, so the neighbors never match. Another is clearing cells while still comparing them. Decide matches from the original value, not the mutated board. Cost is O(rows*cols) per operation, so at most 200 operations on a 200 by 200 board is fine. If you blank under the clock, StealthCoder is the hedge that reads the problem and hands you the solution.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Pop Diagonal Bubbles with Gravity 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Pop Diagonal Bubbles with Gravity FAQ

What's the trick in Pop Diagonal Bubbles with Gravity?+

Don't flood fill. Only the clicked cell and its four direct diagonal neighbors with the same value get removed. Save the clicked value first, zero the matches, then run column gravity. It's a simulation problem, not a graph search.

How do I implement the gravity step cleanly?+

Process each column on its own. Walk from the bottom row up with a write index starting at the last row. Each non-zero value gets placed at the write index, which then moves up. Fill the remaining cells above with zeros. That preserves vertical order.

What happens when the click lands on an empty cell?+

Nothing. Skip the operation entirely, with no removal and no gravity needed. Example 2 shows this: the board comes back unchanged. Check for zero at the start of each operation.

Is the board mutated in place or copied?+

Either works, since you return the final board. Mutating the input is simplest and fast enough. If you worry about side effects, copy it once up front. Don't copy per operation, it's wasteful.

How should I prep for this in 48 hours?+

Write the solution once from scratch. Focus on bounds checks for the four diagonals and the bottom-up compaction loop. Test with both examples and a click on a corner cell. ZipRecruiter reported this in September 2024, so expect similar grid simulation tasks.

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