data-structures · intermediate · ~15 min
Size a region with flood fill.
int max_island_size(const int *grid,int rows,int cols);
Return the number of cells in the largest 4-connected island of 1s (0 if there are none).
grid rows·cols of 0/1.
Biggest island's cell count.
4-directional connectivity.
#include <stddef.h>
/* Size (cell count) of the largest connected region of 1s (4-directional) in a rows x cols grid. 0 if none. */
int max_island_size(const int *grid,int rows,int cols){ (void)grid;(void)rows;(void)cols; return 0; }
Diagonal connectivity; forgetting to track the running maximum.
No 1s → 0; one big blob → its area.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.