When to use it
Reach for Number of islands when a graphs — bfs & dfs problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Pattern
Number of islands is a reusable approach under Graphs — BFS & DFS. Once you recognize the shape of the input and the ask, this pattern gives you a standard plan instead of inventing a new algorithm from scratch.
Reach for Number of islands when a graphs — bfs & dfs problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Reference implementation in C#, Python, Java, JavaScript, and C++.
Interviewers grade pattern recognition. Naming Number of islands early shows you can classify the problem inside Trees & Graphs.
Drill Number of islands with Graphs — BFS & DFS problems — filter the bank and solve 2–3 Easy/Medium items while saying the invariant out loud.
Related Graphs — BFS & DFS problems — open any one and apply Number of islands.
Binary Tree Inorder Traversal
Tree
Validate Binary Search Tree
BST
Same Tree
Tree
Symmetric Tree
Tree
Binary Tree Level Order Traversal
BFS
Binary Tree Zigzag Level Order Traversal
BFS
Maximum Depth of Binary Tree
Tree
Construct Binary Tree from Preorder and Inorder Traversal
Tree
Balanced Binary Tree
Tree