上一页 1 2 3 4 5 6 ··· 22 下一页
摘要: https://kamacoder.com/problempage.php?pid=1176 import java.util.*; public class Main { static int[] dx={0,1,0,-1}; static int[] dy={1,0,-1,0}; static 阅读全文
posted @ 2024-10-18 21:16 风乐 阅读(65) 评论(0) 推荐(0)
摘要: 45. 跳跃游戏 II class Solution { public int jump(int[] nums) { // 最短路做法: // 起始点为0,终点为n-1,边权重为0~nums[i] Deque<int[]> q=new ArrayDeque<>(); boolean[] vis=ne 阅读全文
posted @ 2024-10-15 04:17 风乐 阅读(22) 评论(0) 推荐(0)
摘要: 322. 零钱兑换 class Solution { public int coinChange(int[] coins, int amount) { // 使用图的方式解决 // 最短路问题,总金额从0到amount需要走多少步 // 每一步能迈向的点都是面额里的点+出发点 // 每步的边权都是1 阅读全文
posted @ 2024-10-10 19:01 风乐 阅读(20) 评论(0) 推荐(0)
摘要: 1559. 二维网格图中探测环 class Solution { int[] dx={0,1,0,-1}; int[] dy={1,0,-1,0}; int n; int m; char[][] grid; boolean[][] vis; int startx; int starty; boole 阅读全文
posted @ 2024-10-08 04:53 风乐 阅读(44) 评论(0) 推荐(0)
摘要: 1020. 飞地的数量 class Solution { int[] dx={0,1,0,-1}; int[] dy={1,0,-1,0}; int n; int m; int[][] grid; boolean[][] vis; int res; public int numEnclaves(in 阅读全文
posted @ 2024-10-08 03:57 风乐 阅读(20) 评论(0) 推荐(0)
摘要: 733. 图像渲染 class Solution { int[] dx={0,1,0,-1}; int[] dy={1,0,-1,0}; int n; int m; int[][] image; boolean[][] vis; int color; int sourceColor; public 阅读全文
posted @ 2024-10-08 03:45 风乐 阅读(18) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/pacific-atlantic-water-flow/description/ class Solution { List<List<Integer>> res = new ArrayList<>(); int[] dx={0,1,0,-1 阅读全文
posted @ 2024-10-08 03:34 风乐 阅读(22) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/island-perimeter/description/ 思路:遍历岛屿,一旦遍历到边界或者水则周长++ class Solution { int res; boolean[][] vis; int[][] grid; int[] dx=n 阅读全文
posted @ 2024-10-07 17:49 风乐 阅读(39) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/surrounded-regions/ class Solution { int n; int m; boolean[][] vis; char[][] board; int[] dx=new int[]{0,1,0,-1}; int[] d 阅读全文
posted @ 2024-10-07 17:48 风乐 阅读(18) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/number-of-operations-to-make-network-connected/ 并查集模版题 class Solution { public int makeConnected(int n, int[][] connectio 阅读全文
posted @ 2024-10-07 01:10 风乐 阅读(22) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 22 下一页