Question bank › Graphs Bfs
Dsa Graphs Bfs Medium

Minimum Path in Warehouse

There is a warehouse represented by a 2D grid where '0's are empty spaces and '1's are obstacles. Given the grid and the starting point (row, column), determine the minimum number of moves required to reach the nearest edge of the grid. You can move up, down, left or right. If there’s no possible path to the edge, output -1. Input consists of the dimensions R and C followed by R lines of the grid and the starting coordinates. Output the minimum number of moves. Example: Input: 4 4 0110 0000 0110 1110 1 1 Output: 2

Key concepts

graphsbfsshortest-path

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.