Basic count
Iterate cells. For each unvisited '1', BFS/DFS to mark whole island. Increment count.
Advertisement
Max area
Same, but track island size. Return max.
Advertisement
Distinct shapes
Normalize each island (translate to origin) → hash → count distinct hashes.
Making an island
Given water cells, which single flip creates biggest merged island? Preprocess island IDs + sizes; for each water cell, sum sizes of neighboring distinct islands + 1.