Find the Number of Islands

Prereq: BFS on Graph

Given a 2-dimensional matrix of values with 0 and 1, count the number of islands of 1. An island consists of all value 1 cells and is surrounded by either an edge or all 0 cells. A cell can only be adjacent to each other horizontally or vertically, not diagonally.



Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions