GoLang Solution For LeetCode Problem: Number of Enclaves
Solving Number of Enclaves in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.
Problem Description
A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.
Example 1:
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.
Example 2:
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.
Note:
1 <= A.length <= 500
1 <= A[i].length <= 500
0 <= A[i][j] <= 1
- All rows have the same size.
- 1 <= A.length <= 500
- 1 <= A[i].length <= 500
- 0 <= A[i][j] <= 1
See the full details of the problem Number of Enclaves at LeetCode
Originally posted at: @github.com/halfrost/LeetCode-Go
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.