Find path to the end of a maze with doors and walls using special glasses
Filed under MakeMyTrip
Free read 3 of 3Use BFS where state is (row, col, glass_type).
The question
Find the minimum time to reach the bottom-right of a grid maze containing walls and doors, given two types of glasses that allow passing through walls or doors respectively.
Constraints
- Grid size N x M
- Two types of glasses
- Minimum time/steps
Approach
Use BFS where state is (row, col, glass_type).
Explore neighbors; if a cell is a wall/door, check if the current glass allows passage.
Allow switching glasses at specific nodes if the problem rules permit.
BFS naturally finds the shortest path in an unweighted grid.
Tips
- What they are testing: Tests graph traversal algorithms (BFS) and state management.
- Common mistake: Treating the state as just (x, y) instead of (x, y, current_glass).
Related MakeMyTrip questions
Collected from public candidate posts and coding forums. Updated Nov 2026.