Given the matrix M [r] [c] filled with zeros and ones. Zero - the sea, 1 - land. An island is land, surrounded by the sea in columns or in a row. The island cannot be inside the island.
The task is to find the number of islands.
Example:
In
[[0, 1, 1],
[1, 0, 1],
[0, 1, 0]]
Out
3
In
[[1, 1, 1, 1, 1],
[1, 0, 0, 0, 1],
[1, 0, 1, 0, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1]]
Out
one
In
[[1, 0, 1],
[0, 1, 1]]
Out
2
In
[[1, 1, 1],
[1, 0, 1],
[1, 0, 1]]
Out
one
Question: what algorithms solve a similar problem, or ideas to solve this problem.

0