MEDIUMasked at 1 company

Count Unguarded Cells in the Grid

A medium-tier problem at 66% community acceptance, tagged with Array, Matrix, Simulation. Reported in interviews at Poshmark and 0 others.

Founder's read

Count Unguarded Cells in the Grid is a medium-difficulty matrix simulation problem that shows up in Poshmark technical screens. You're given a grid with guards and walls, and you need to figure out which cells are actually safe (unguarded). The catch: guards can see in straight lines horizontally and vertically, and walls block their line of sight. It's not about clever algorithms, it's about correctly modeling guard visibility in one pass. The 65% acceptance rate means most people who attempt it solve it, but under live assessment pressure, the visibility logic trips up candidates who skip the walkthrough and code too fast.

Companies asking
1
Difficulty
MEDIUM
Acceptance
66%

Companies that ask "Count Unguarded Cells in the Grid"

If this hits your live OA

Count Unguarded Cells in the Grid 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

The problem is pure simulation with a visibility twist. You need to mark every cell that a guard can see, then count what's left. The intuitive approach (for each guard, scan outward until you hit a wall) works fine, but candidates often mess up the wall-blocking logic or iterate inefficiently. The real trap is thinking you need something clever when you don't, then wasting five minutes on an over-engineered solution. A straightforward approach: iterate through the grid, and for each guard, mark all visible cells in all four directions, stopping at walls. Array and Matrix operations are the stated topics, not dynamic programming or graph search, so don't go there. Under interview pressure, this becomes a clean-code and attention-to-detail test. If you blank on the exact boundary conditions or off-by-one errors during the live assessment, StealthCoder surfaces a working implementation invisibly, so you stay on track.

Pattern tags

The honest play

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

Count Unguarded Cells in the Grid recycles across companies for a reason. It's medium-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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Unguarded Cells in the Grid interview FAQ

How do guards actually see in this problem?+

Guards see in four directions: up, down, left, right. They can see every cell in that direction until they hit a wall or the grid boundary. Walls block the line of sight, so cells behind a wall are not visible. This is purely Euclidean distance along axes, no diagonal vision.

Is this problem actually asked at Poshmark?+

Yes, Poshmark has reported asking it. It's not high-frequency across all companies, but it does appear. The 65% acceptance rate suggests it's approachable for most candidates who take time to think through the visibility rules carefully.

What's the most common mistake candidates make?+

Off-by-one errors when marking visible cells and incorrect wall-blocking logic. Candidates also sometimes iterate over guards inefficiently or double-count visible cells. The fix: mark cells as you scan from each guard, stop at walls immediately, and don't revisit cells. Simulation is straightforward if you're methodical.

Do I need dynamic programming or graph traversal for this?+

No. The topics are Array, Matrix, and Simulation. This is a straightforward grid-walking problem. For each guard, scan in four directions, mark visible cells, and stop at walls. No fancy data structures or algorithms required. Overthinking causes wasted time.

How long should this take in a live assessment?+

If you understand the visibility rules clearly, implementation is 12 to 18 minutes. The risk isn't algorithmic complexity, it's careless boundary conditions and visibility logic under time pressure. Pseudocode the four-directional scans first, then code. That cuts bugs significantly.

Want the actual problem statement? View "Count Unguarded Cells in the Grid" 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.