Leetcode_1020_飞地的数量_dfs
朴实无华的深搜
class Solution {
int n;
int m;
int ans;
boolean[][] vis;
int[][] grid;
int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
public int numEnclaves(int[][] grid) {
n = grid.length;
m = grid[0].length;
ans = 0;
vis = new boolean[n][m];
this.grid = grid;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
版权声明:
作者:zhangchen
链接:https://www.techfm.club/p/18892.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论