Practice
Learn
← Quit
0 / 0 correct
Algorithms
Hard
1 of 433
Why does 'number of islands' use BFS/DFS or union-find?
A
It needs sorting
B
Each island is a connected component of land cells; flood fill or union-find counts components in O(rows × cols)
C
It's a shortest path problem
D
It needs dynamic programming