Question bank › Graphs Bfs
Dsa Graphs Bfs Medium

Minimum Moves to Destination

You are on a game board represented as a grid of size N x N. You start at the top-left corner and want to reach the bottom-right corner using the minimum number of moves. You can move to any adjacent cell (up, down, left, right), as well as diagonally. Each move to an adjacent cell counts as 1. Write a function to find the minimum moves required to reach the destination cell. Input: - The first line contains a single integer N (size of grid). - The next N lines contain N characters ('0' for a walkable cell and '1' for a blocked cell). Output: - Print the minimum number of moves to reach the bottom-right corner from the top-left corner. If it is not possible, print -1. Example: Input: 3 000 010 000 Output: 4

Key concepts

graphsbfsminimum_moves

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.