10 2024 档案

摘要: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 风乐 阅读(52) 评论(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 风乐 阅读(13) 评论(0) 推荐(0)
摘要:322. 零钱兑换 class Solution { public int coinChange(int[] coins, int amount) { // 使用图的方式解决 // 最短路问题,总金额从0到amount需要走多少步 // 每一步能迈向的点都是面额里的点+出发点 // 每步的边权都是1 阅读全文
posted @ 2024-10-10 19:01 风乐 阅读(12) 评论(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 风乐 阅读(21) 评论(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 风乐 阅读(8) 评论(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 风乐 阅读(8) 评论(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 风乐 阅读(11) 评论(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 风乐 阅读(28) 评论(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 风乐 阅读(9) 评论(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 风乐 阅读(13) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/redundant-connection/ class Solution { public int[] findRedundantConnection(int[][] edges) { // 思路:遍历边,不断的加入相连的点到集合中,直到遍历 阅读全文
posted @ 2024-10-06 22:51 风乐 阅读(12) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/number-of-provinces/ 并查集模版题 class Solution { int[] p; void init(int n) { p=new int[n]; for(int i=0;i<n;i++)p[i]=i; } int 阅读全文
posted @ 2024-10-06 21:09 风乐 阅读(16) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/get-equal-substrings-within-budget/description/ 滑动窗口,固定的套路是,固定右端点枚举,缩小左端点维护合法的窗口状态,在维护使得合法后(状态变化具有单调性,即扩大区间,状态是单调变化的),左端点 阅读全文
posted @ 2024-10-06 03:33 风乐 阅读(10) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/permutation-in-string/description/ class Solution { public boolean checkInclusion(String S1, String S2) { // 看数据范围以及感觉,是双 阅读全文
posted @ 2024-10-06 03:16 风乐 阅读(11) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/minimum-window-substring/description/ 难点在于解决字符出现次数的计算以及如何理解[涵盖],如何判断是否涵盖 class Solution { public String minWindow(String 阅读全文
posted @ 2024-10-06 02:43 风乐 阅读(14) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/subarray-product-less-than-k/description/ 同向双指针,没什么难点 class Solution { int res; public int numSubarrayProductLessThanK(in 阅读全文
posted @ 2024-10-06 00:24 风乐 阅读(7) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/ 同向双指针问题,利用hashmap判重 class Solution { int res; public int leng 阅读全文
posted @ 2024-10-06 00:22 风乐 阅读(13) 评论(0) 推荐(0)