Problem library

Island Count

Easy
matrixflood fill

An arena map is a list of equal-length strings. # is land and . is water. Land cells that touch up, down, left or right belong to the same island (diagonals do not connect).

Return the number of islands. A map can be empty.

Examples

Input: map = ["##..","#..#","..##"]
Output: 2
Input: map = ["...","..."]
Output: 0