This question flunked me. :(
Given matrix with 0 as water and 1 as island, find the number of island in each distinct group of connected of island.
If any island has another island in its proximity (all 8 adjacent vertex), then they are connected.
[[0, 1, 0],
[0, 0, 0],
[0, 1, 0]]
Ans: [1, 1], there are 2 chain of island with 1 island each
[[0, 1, 0],
[1, 0, 0],
[0, 1, 0]]
Ans [3] 1 chain of island with 3 island on it
[[0, 1, 1],
[0, 0, 0],
[0, 1, 0]]
Ans [2, 1] 2 chain of island and 2 island on first and 1 island on another.