Count how many separate islands of land exist in a 2D grid.
You are given a 2D grid of characters where each cell is either land ('1') or water ('0'). An island is a group of land cells connected horizontally or vertically. Diagonal adjacency does not count.
Return the number of distinct islands in the grid.
Example 1
Input
grid = [ ['1','1','0','0','0'], ['1','1','0','0','0'], ['0','0','1','0','0'], ['0','0','0','1','1'] ]
Output
3
Explanation
There are three separate islands: one in the top-left, one in the middle, and one in the bottom-right.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.