A CodeSignal problem gives you a matrix and asks for the number of islands (connected groups of 1s). Which algorithm is best suited?
-
A
Dijkstra's shortest path
-
B
BFS or DFS flood-fill from each unvisited land cell
-
C
Binary search on the matrix rows
-
D
Topological sort