Number of Islands II

Given an initially all-water m × n grid, process k operations. Each operation turns position (r, c) into land. After every operation, output the current number of islands.

Land cells connected ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: