MEDIUMasked at 5 companies

Shortest Path in Binary Matrix

A medium-tier problem at 50% community acceptance, tagged with Array, Breadth-First Search, Matrix. Reported in interviews at Meta and 4 others.

Founder's read

Shortest Path in Binary Matrix hits your OA and you blank on the direction vectors. It's a medium-difficulty BFS problem that shows up at Meta, Airbnb, Snap, Intuit, and Palo Alto Networks. The trap is thinking depth-first or getting lost in the grid traversal logic. Nearly half of candidates fail it on first submission, usually because they miss that diagonal movement counts or they don't handle the start/end edge cases correctly. If this problem lands in your assessment and you hit a wall, StealthCoder solves it invisibly in seconds with a working solution.

Companies asking
5
Difficulty
MEDIUM
Acceptance
50%

Companies that ask "Shortest Path in Binary Matrix"

If this hits your live OA

Shortest Path in Binary Matrix 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

This is a pure BFS problem, but the trick most candidates miss is the eight-directional movement. You're finding the shortest path from top-left to bottom-left in a grid where 0 is passable and 1 is blocked. The obvious move is to code up a standard BFS queue, but you need to initialize correctly: check if the start cell is blocked (return -1), and explore all eight neighbors (up, down, left, right, plus the four diagonals). Common failures happen when candidates forget diagonals entirely, or when they don't track visited cells properly and end up in infinite loops. The pattern itself is textbook BFS with a level-order traversal to count steps. If you've drilled shortest-path problems on grids before, this feels familiar. If you haven't, the directional complexity can trip you up live. StealthCoder is your hedge for that one missed pattern during screen share.

Pattern tags

The honest play

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

Shortest Path in Binary Matrix 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.

Shortest Path in Binary Matrix interview FAQ

Do I really need to check all eight directions in this problem?+

Yes. The problem allows diagonal movement (up-left, up-right, down-left, down-right), not just cardinal directions. This is why the problem is harder than a standard four-direction BFS. Miss diagonals and your path won't be optimal.

Why is acceptance rate so low for a medium problem?+

It's 50 percent. The directional logic and edge cases (blocked start, blocked end, single cell) trip up candidates who haven't drilled grid-based BFS before. It's not algorithmically hard, but the details matter.

Is this problem still asked at big companies like Meta and Airbnb?+

Yes, consistently. Five major companies are on the reported list: Meta, Airbnb, Snap, Intuit, and Palo Alto Networks. It's a reliable screening problem for engineers who need to show grid-traversal competence.

What's the most common mistake candidates make?+

Forgetting to mark cells as visited or not initializing the visited set properly, which leads to cycles. Also, mishandling the start or end being blocked, or not counting the distance correctly as you traverse levels.

How does this relate to other array and matrix problems I should know?+

It's a direct application of BFS with Array and Matrix topics. If you're solid on classic problems like Number of Islands or Rotting Oranges, you'll recognize the pattern. This is the harder cousin because of the diagonal movement and tighter acceptance rate.

Want the actual problem statement? View "Shortest Path in Binary Matrix" 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.