Skip to content

Commit 4328ec8

Browse files
Update and rename NoOfEnclaves.cpp to medium-1020-number_of_enclaves.cpp
1 parent 11096bb commit 4328ec8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Codes/NoOfEnclaves.cpp renamed to Codes/medium-1020-number_of_enclaves.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
// You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell.
2+
3+
// A move consists of walking from one land cell to another adjacent (4-directionally) land cell or walking off the boundary of the grid.
4+
5+
// Return the number of land cells in grid for which we cannot walk off the boundary of the grid in any number of moves.
6+
7+
8+
9+
// Example 1:
10+
11+
12+
// Input: grid = [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
13+
// Output: 3
14+
// Explanation: There are three 1s that are enclosed by 0s, and one 1 that is not enclosed because its on the boundary.
15+
// Example 2:
16+
17+
18+
// Input: grid = [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]]
19+
// Output: 0
20+
// Explanation: All 1s are either on the boundary or can reach the boundary.
21+
22+
123
class Solution {
224
void dfs(vector<vector<int>> &grid,int i,int j){
325
int x[4]={0,0,1,-1};

0 commit comments

Comments
 (0)