← Samsung questions

Shortest path in matrix

Filed under Samsung · Also reported at Adobe

Given an M x N grid containing 0s (passable) and 1s (obstacles), find the shortest path distance from a starting cell (r1, c1) to a target cell (r2, c2). If no path exists, return -1.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Samsung questions

Collected from public candidate posts and coding forums. Updated Nov 2026.