NiuNiu MaTe
Nov 24, 2021 · Fundamentals
How to Count Islands in a Grid Using DFS and BFS – Step‑by‑Step Guide
This article explains the classic "Number of Islands" problem, presents two example grids, and demonstrates how depth‑first search (DFS) and breadth‑first search (BFS) can be applied to count isolated land masses in a 2D matrix.
BFSDFSgraph traversal
0 likes · 6 min read
