Loading…
Loading…
Given a grid of 0s and 1s, return the area (cell count) of the largest island (4-directionally connected group of 1s). Print 0 if there is no island.
Input:
11 1 0 0
20 1 0 0
30 0 0 1Output: 3
Same flood-fill scan as Number of Islands, but each DFS/BFS call returns the size of the island it just explored instead of just marking it — track the maximum size seen.
Line 1: number of rows R Next R lines: space-separated grid row
Input (stdin)
Output
Input (stdin)
Output
Sign in to track solved problems and earn XP.