Search⌘ K
AI Features

Solution: Number of Islands II

Explore the union-find algorithm applied to the Number of Islands II problem, where you dynamically add land cells to a grid and track the count of islands. This lesson teaches you how to efficiently manage connectivity and updates using union-find, helping you grasp a key graph algorithm pattern for coding interviews.

Statements

You are given a 2D2D binary grid of size m×nm × n. In this grid, 00 represents water and 11 ...