Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Number of Islands II

An m x n grid starts as all water. Land cells are added one by one. After each addition print the current number of islands (4-directionally connected land).

Constraints

1 <= m, n, p <= 10^4 (m * n <= 10^5)

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.