Count Islands and Make a Large Island
You are given a 2D grid consisting of characters '1'
representing land and '0'
representing water. Your task is to determine how many distinct islands exist in the grid. An island is defined as a group of horizontally or vertically adjacent lands surrounded by water. The edges of the grid are considered to be water.
Example 1:
Grid: 11100 11000 10011 00000 Number of islands: 2
Example 2:
Grid: 10100 10100 00010 01110 Number of islands: 4
'1'
or '0'