Reported September 2024
ZipRecruitersimulation

Drop a Connected Figure Through Obstacles

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 data structure here is just a list of coordinates. ZipRecruiter reported this one in September 2024, and it looks harder than it is. You get a grid with empty cells, # obstacles, and one connected figure of F cells. Slide the whole figure down until something blocks it, then print the grid. If you've got an OA coming in the next day or two, this is a simulation problem with one clean idea. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but you probably won't need it once you see the shape of this.

The problem

A rectangular grid uses. for empty, # for obstacles, and F for one orthogonally connected rigid figure.
Move the complete figure downward as far as possible without any figure cell leaving the grid or overlapping an obstacle. Return the final grid.

Function
dropFigure(grid: String[]) → String[]

Examples
Example 1
grid = [".F.",".F.","...",".#."]
return = ["...",".F.",".F.",".#."]
The figure falls one row before its lower cell would hit the obstacle.
Example 2
grid = ["F..","..."]
return = ["...","F.."]
The figure falls to the bottom.

Constraints
1 <= rows,columns <= 200

Reported by candidates. Source: FastPrep

Pattern and pitfall

Collect every F cell as a (row, col) pair. Now the figure is rigid, so every cell drops by the same amount k. For each column that contains F cells, take only the lowest F cell in that column. Count the empty cells below it until you hit a # or the grid edge. The answer k is the minimum of those counts across all columns. Why the lowest cell per column? Upper F cells in the same column move with it and never block each other. The pitfall is simulating one row at a time and checking only the bottom row of the figure, which breaks on L or S shapes where cells sit at different heights. Another trap is moving cells in place and overwriting your own F cells. Clear all F cells first, then write them at row + k. That's O(rows * columns) with a 200 by 200 grid, which is trivial. If you freeze live, StealthCoder can hand you the finished solution.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Drop a Connected Figure Through Obstacles 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Drop a Connected Figure Through Obstacles FAQ

How hard is the ZipRecruiter drop figure problem really?+

Easy to medium. There's no fancy algorithm. The difficulty is realizing the figure is rigid, so you compute one shared drop distance instead of moving cells individually. Once you see that, it's about 20 lines of code and a single pass over the grid.

What's the trick to getting the drop distance?+

For each column containing F, find the lowest F cell. Count how many consecutive non-obstacle cells sit below it until a # or the grid bottom. The figure's drop distance is the minimum of those counts across all columns that hold F cells.

Why not just move the figure down one row at a time?+

You can, and it passes at 200 by 200. But you must check every F cell against its destination, ignoring cells that are F themselves. Checking only the figure's bottom row fails on irregular shapes. The min-per-column approach avoids that bug entirely.

What edge cases should I test before submitting?+

Test a figure already resting on an obstacle or the bottom, which should return the grid unchanged. Test a one-row grid. Test a figure with a gap in a column, like a U shape, where an obstacle sits between F cells. Also confirm obstacles never move.

How do I prepare for this in 48 hours?+

Practice grid simulation problems where you collect coordinates, compute a shared shift, clear the old cells, then write the new ones. Write this exact problem twice from scratch. Focus on the clear-then-write order so you never overwrite your own cells.

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