Number of Islands
BFS/DFS + Visited Marking Pattern · Interactive Visualizer & Interview Guide
Related problems
Same BFS/DFS mental model
✕
← Back to Number of Islands
Understand the pattern
Explain to interviewer
Java code
Why BFS?
Complexity
Use the controls to step through the BFS traversal, or click Run all to watch it animate.
Example 1 (1 island)
Example 2 (3 islands)
Land '1'
Water '0'
Current (BFS front)
Visited
Island found
BFS Queue:
0
islands found
Reset
← Back
Step →
Run all