Problem Statement
Given an m x n 2D binary grid grid which represents a map of "1"s (land) and "0"s (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
Approach
Iterate through every cell. If we encounter a "1", increment island count and start a DFS/BFS to mark all connected "1"s as visited (or turn them to "0").
Time & Space Complexity
Time complexity is O(M * N) where M is rows and N is cols. Space complexity is O(M * N) for the recursion stack/queue in worst case.
