Number of Islands

Prereq: BFS on Graph

A map is represented as a 2D grid of 1s and 0s where 1 represents land and 0 represents water. An island is a horizontally and vertically (but not diagonally) continuous block of lands surrounded by water. Find the number of islands on the map. Assume cells beyond grid boundaries are water.