A grid has cells marked # (land) or . (water). Two land cells belong to the same island if they share a side (up, down, left or right). Count the islands.
The first line has R and C. Each of the next R lines has a string of C characters.
Print the number of islands.
1 <= R, C <= 1000
1000 ms256 MB
4 5 ##..# #...# ..#.. .....
3
One island in the top-left, one on the right edge, and the single cell in the middle.