Question bank › Graphs Dfs
Dsa Graphs Dfs Easy

Longest Path in Maze

You are given a 2D grid representing a maze, where 1s are walls and 0s are paths. Write a program to find the length of the longest path that can be taken through the maze without retracing your steps. The path can only move up, down, left, or right. Input format: The first line contains two integers, m and n (1 <= m, n <= 50), the dimensions of the grid. The next m lines each contain n integers (0 or 1) separated by spaces, describing the maze. Output the length of the longest path. Example: Input: 3 3 0 0 1 0 0 0 1 0 0 Output: 4

Key concepts

graphsdfspathfinding

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.