# Number of islands

MediumYou're given a

`m x n`

2D grid of 1s and 0s, where 1 represents land and 0 represents water, find the number of islands that exist in the grid.Consider an

*island*as a group of*adjacent*1s.*Adjancent*cells are cells that are in either 4 directions - left, right, down, or up.

For example, given the following grid

grid = [[1, 0, 0],[0, 1, 1],[0, 1, 0]]

Your function should return

`2`

.## Try it

Before you look at the solution, try to code it yourself.

## Solution

## 9 Essential Trees & Graphs Coding Interview Problems

Master Trees & Graphs by trying the coding challenges below.

- 1.Inorder TraversalEasy
- 2.Tree SumEasy
- 3.Tree HeightEasy
- 4.LCAMedium
- 5.Max Path SumHard
- 6.Search mazeMedium
- 7.Number of islandsMedium
- 8.Kth SmallestMedium
- 9.Sort K ArraysHard