Problem context and objectives
Mission briefing
Expedition navigator · Safe camps and hazards form a connected world map
Find a valid route while marking every place already explored: Diagonal Escape.
Without visited state, the party loops forever or revisits expensive terrain.
How you win
- 1Recognize when Shortest path in a binary matrix matches the clues
- 2Keep this true after every move: every queued cell has the shortest open path length from the top-left cell
- 3Reach the result within O(rows times columns) time and space
Rules and pressure
- Target cost: O(rows times columns) time and space
- State rule: every queued cell has the shortest open path length from the top-left cell
Lesson 1 of 3
Treat every open cell as a graph node and spread complete distance rings in all eight directions.
Your call · Which open cells belong to the first ring from start (0,0)?