When to use it
Reach for Number of islands when a matrices & grids 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 Matrices & Grids. 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 matrices & grids 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 Patterns.
Drill Number of islands with Matrices & Grids problems — filter the bank and solve 2–3 Easy/Medium items while saying the invariant out loud.
Related Matrices & Grids problems — open any one and apply Number of islands.