会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
gloomyjohn
博客园
首页
新随笔
联系
订阅
管理
2025年2月20日
LeetCode Hot100_560. 和为k的子数组
摘要: 题目链接:https://leetcode.cn/problems/subarray-sum-equals-k/?envType=study-plan-v2&envId=top-100-liked 暴力解法: 第一层循环左边界,第二层循环有边界,sum一直加,加到等于target就让cnt++。 p
阅读全文
posted @ 2025-02-20 09:23 烟雨化飞龙
阅读(2)
评论(0)
推荐(0)
2025年2月14日
LeetCode Hot100_438.找到字符串中所有字母异位词
摘要: 题目链接: https://leetcode.cn/problems/find-all-anagrams-in-a-string/description/?envType=study-plan-v2&envId=top-100-liked 滑动窗口: import java.util.*; clas
阅读全文
posted @ 2025-02-14 09:24 烟雨化飞龙
阅读(2)
评论(0)
推荐(0)
2025年2月13日
LeetCode Hot100_3.无重复字符的最长字串
摘要: 题目链接: https://leetcode.cn/problems/longest-substring-without-repeating-characters/?envType=study-plan-v2&envId=top-100-liked 滑动窗口: 如果扫描到重复了的字符,就重新计算左侧
阅读全文
posted @ 2025-02-13 10:00 烟雨化飞龙
阅读(5)
评论(0)
推荐(0)
2025年2月11日
LeetCode Hot100_42.接雨水
摘要: 题目链接: 动态规划: 以前做过一遍但是还是忘掉了qaq...看了力扣的题解也没想起来 首先确定动态规划数组的含义,leftmax[i]表示i及i左边最高的柱子,这些柱子可能代表了能接到的最多的雨水;同样rightmax[i]代表i及i右边最高的柱子。 第二推导公式: leftMax[i] = Ma
阅读全文
posted @ 2025-02-11 15:44 烟雨化飞龙
阅读(12)
评论(0)
推荐(0)
2025年2月9日
LeetCode Hot100_15. 三数之和
摘要: 题目链接:15. 三数之和 - 力扣(LeetCode) 三个指针法: i指针从头开始遍历指导倒数第三个,在循环内设置指针j、k,初始值分别为i+1和n-1,这样就都能遍历到。 1 class Solution { 2 public List<List<Integer>> threeSum(int[
阅读全文
posted @ 2025-02-09 11:37 烟雨化飞龙
阅读(7)
评论(0)
推荐(0)
LeetCode Hot100_11. 盛水最多的容器
摘要: 题目链接:11. 盛最多水的容器 - 力扣(LeetCode) 贪心算法: 双指针,指向容器的两个边界。 1 class Solution { 2 public int maxArea(int[] height) { 3 int i = 0,j = height.length-1; 4 int ma
阅读全文
posted @ 2025-02-09 10:55 烟雨化飞龙
阅读(5)
评论(0)
推荐(0)
Leetcode hot100_283.移动零
摘要: 题目链接:283. 移动零 - 力扣(LeetCode) 暴力解法: 感觉像用了冒泡排序呢)只是把比较大小的if语句变成了判断是否为0. 1 class Solution { 2 public void moveZeroes(int[] nums) { 3 if(nums.length <= 1)
阅读全文
posted @ 2025-02-09 10:25 烟雨化飞龙
阅读(10)
评论(0)
推荐(0)
2025年2月8日
Leetcode hot100_128. 最长连续子序列
摘要: 题目链接:128. 最长连续序列 - 力扣(LeetCode) 贪心方法:从头遍历num数组,不断更新count计数器和最大长度max,用pre记录前一个连续的数字。 1 class Solution { 2 public int longestConsecutive(int[] nums) { 3
阅读全文
posted @ 2025-02-08 16:42 烟雨化飞龙
阅读(3)
评论(0)
推荐(0)
Leetcode hot100_49.字母异位词分组
摘要: 题目链接:49. 字母异位词分组 - 力扣(LeetCode) 暴力解法套for循环 不是很想这么做捏 先想到了整个数组排序后再一个一个扫描。可以直接对每个小字符串进行排序然后一样的加入map 1 class Solution { 2 public List<List<String>> groupA
阅读全文
posted @ 2025-02-08 16:32 烟雨化飞龙
阅读(8)
评论(0)
推荐(0)
Leetcode hot100刷题记录_1.两数之和
摘要: 题目链接:1. 两数之和 - 力扣(LeetCode) 暴力解法: 1 class Solution { 2 public int[] twoSum(int[] nums, int target) { 3 for(int i = 0;i < nums.length-1 ; i++){ 4 for(i
阅读全文
posted @ 2025-02-08 09:56 烟雨化飞龙
阅读(39)
评论(0)
推荐(0)
下一页
公告