上一页 1 2 3 4 5 6 ··· 21 下一页
摘要: 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 风乐 阅读(14) 评论(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 风乐 阅读(16) 评论(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 风乐 阅读(35) 评论(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 风乐 阅读(16) 评论(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 风乐 阅读(18) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/redundant-connection/ class Solution { public int[] findRedundantConnection(int[][] edges) { // 思路:遍历边,不断的加入相连的点到集合中,直到遍历 阅读全文
posted @ 2024-10-06 22:51 风乐 阅读(22) 评论(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 风乐 阅读(20) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/get-equal-substrings-within-budget/description/ 滑动窗口,固定的套路是,固定右端点枚举,缩小左端点维护合法的窗口状态,在维护使得合法后(状态变化具有单调性,即扩大区间,状态是单调变化的),左端点 阅读全文
posted @ 2024-10-06 03:33 风乐 阅读(17) 评论(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 风乐 阅读(17) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/minimum-window-substring/description/ 难点在于解决字符出现次数的计算以及如何理解[涵盖],如何判断是否涵盖 class Solution { public String minWindow(String 阅读全文
posted @ 2024-10-06 02:43 风乐 阅读(20) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 21 下一页