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: Island Census.
Without visited state, the party loops forever or revisits expensive terrain.
How you win
- 1Recognize when Number of islands matches the clues
- 2Keep this true after every move: all land before the scan position has been assigned to exactly one counted island
- 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: all land before the scan position has been assigned to exactly one counted island
Lesson 1 of 3
Count one island at the first unseen land cell, then survey its complete four-direction component.
Your call · Which cells belong to the first flood from root (0,0)?