Given a `grid` of `1`s (land) and `0`s (water), implement `numIslands(grid)` returning the number of islands. An island is a group of `1`s connected horizontally or vertically.
+ 2 hidden tests run on Submit.
Each time the scan meets land that has not been flooded, it is the start of a fresh island; a DFS then sinks the whole connected component. Every cell is visited a constant number of times, so it runs in O(rows × cols).
Run your code to see results.