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