Number of Enclaves
Given a 2D arrayA, each cell is 0 (representing sea) or 1 (representing land)Input:
[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
Output:
3
Explanation:
There are three 1s that are enclosed by 0s, and one 1 that isn't enclosed because its on the boundary.Input:
[[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
Output:
0
Explanation:
All 1s are either on the boundary or can reach the boundary.Last updated