摘要: 深度优先搜索 class Solution { int m; int n; boolean[][] used; int[][] move = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public void solve(char[][] board) { m = boa 阅读全文
posted @ 2022-01-16 22:44 振袖秋枫问红叶 阅读(34) 评论(0) 推荐(0)
摘要: 深度优先搜索 import java.util.ArrayList; import java.util.HashMap; class Solution { int m; int n; boolean[][] used; int[][] move = {{0, 1}, {1, 0}, {0, -1}, 阅读全文
posted @ 2022-01-16 21:53 振袖秋枫问红叶 阅读(109) 评论(0) 推荐(0)
摘要: 深度优先搜索 class Solution { int m; int n; boolean[][] used; int sum = 0; int[][] move = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public int islandPerimeter(int 阅读全文
posted @ 2022-01-16 18:56 振袖秋枫问红叶 阅读(30) 评论(0) 推荐(0)
摘要: 深度优先搜索 class Solution { int m; int n; boolean[][] used; int[][] move = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public int maxAreaOfIsland(int[][] grid) { 阅读全文
posted @ 2022-01-16 17:50 振袖秋枫问红叶 阅读(28) 评论(0) 推荐(0)
摘要: 深度优先搜索 class Solution { int m; int n; int sum; boolean[][] used; int[][] move = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; public int numIslands(char[][] gri 阅读全文
posted @ 2022-01-16 16:59 振袖秋枫问红叶 阅读(37) 评论(0) 推荐(0)
摘要: 回溯 class Solution { int m; int n; boolean[][] used; /** * 使用辅助数组来进行上右下左遍历 */ int[][] move = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; public boolean exist(c 阅读全文
posted @ 2022-01-16 11:32 振袖秋枫问红叶 阅读(32) 评论(0) 推荐(0)