Given a boolean 2D matrix, find the number of islands.
What is an island?
A group of connected 1s forms an island. For example, the below matrix contains 5 islands
A group of connected 1s forms an island. For example, the below matrix contains 5 islands
{1, 1, 0, 0, 0},
{0, 1, 0, 0, 1},
{1, 0, 0, 1, 1},
{0, 0, 0, 0, 0},
{1, 0, 1, 0, 1}
Question 2: Connected Cells in a Grid
No comments:
Post a Comment