The first line of input contains two integer values, 'N' and 'M', separated by a single space. They represent the 'rows' and 'columns' respectively, for the two-dimensional array/list.
The second line onwards, the next 'N' lines or rows represent the ith row values.
Each of the i-th row constitutes 'M' column values separated by a single space.
The only line of output prints the number of islands present in the 2-dimensional array.
You are not required to print anything explicitly, it has already been taken care of. Implement the function and return the desired output.
1 <= N <= 10^3
1 <= M <= 10^3
0 <= ARR[i][j] <= 1
Time limit: 1sec
We can use the flood fill algorithm to check for all connected 1s.