## Orginal Problem

1 | # Given a 2D array binaryMatrix of 0s and 1s, implement a function getNumberOfIslands that returns the number of islands of 1s in binaryMatrix. |

## Approach

The problem is asking us to identify the number of islands or cluster of 1s in a binary matrix. If we simply count the number of 1s it’ll be difficult to track which 1 belong to which cluster and thus will not give accurate answer. The depth first traversal approach is one that’s easy to understand, we’ll loop over the entire matrix and if the number is an 1, we will utlize dpeth first traversal to find all 1s linked or inter-linked to the 1 that initiated the dfs.

## Implementation

First, we must create a function to loop over the matrix

1 | def count_island(bm): # bm: binary matrix |

Following we can write a depth first traversal function to traverse all 1s in a cluster.

1 | def dfs(bm, r, c): |