MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / numEnclaves

Method numEnclaves

java/1020-number-of-enclaves.java:32–45  ·  view source on GitHub ↗
(int[][] board)

Source from the content-addressed store, hash-verified

30 dfs(r, c-1, board);
31 }
32 public int numEnclaves(int[][] board) {
33 int n=board.length, m=board[0].length;
34
35 for(int i=0; i<n; i++){
36 if(board[i][0] == 1) dfs(i, 0, board);
37 if(board[i][m-1] == 1) dfs(i, m-1, board);
38 }
39
40 for(int i=1; i<m-1; i++){
41 if(board[0][i] == 1) dfs(0, i, board);
42 if(board[n-1][i] == 1) dfs(n-1, i, board);
43 }
44 return count(board);
45 }
46}

Callers

nothing calls this directly

Calls 2

dfsMethod · 0.95
countMethod · 0.95

Tested by

no test coverage detected