Search
⌘K

Leetcode 1020. Number of Enclaves

Count the number of land cells (1s) that belong to connected components that cannot reach the grid boundary. The core challenge is to identify and exclude all land reachable from the boundary (e.g., via BFS/DFS flood-fill) and return the size of the remaining enclosed components; m,n ≤ 500 so an O(mn) solution is expected.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.