hot100
哈希(2025/7/5) 1两数之和思路这里写(copy)一点思路: 注意到方法一的时间复杂度较高的原因是寻找 target - x 的时间复杂度过高。因此,我们需要一种更优秀的方法,能够快速寻找数组中是否存在目标元素。如果存在,我们需要找出它的索引。 使用哈希表,可以将寻找 target - x 的时间复杂度降低到从 O(N) 降低到 O(1)。 这样我们创建一个哈希表,对于每一个 x,我们首先查询哈希表中是否存在 target - x,然后将 x 插入到哈希表中,即可保证不会让 x 和自己匹配。 代码 1234567891011121314class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> hashtable = new HashMap<Integer, Integer>(); //new 出来要加() int n =...
Hello World
Welcome to My first Blog. Today is 2025-07-01.二战上岸后,终于还是决定转java了,要么测开,要么agent吧,希望未来三年能好过一点。置顶页教程参考:title: 文章标题date: 创建日期updated: 更新日期cover: 文章封面description: 文章描述swiper_index: 1 #置顶轮播图顺序,非负整数,数字越大越靠前 页面配置Front-matter 是 markdown 文件最上方以—分隔的区域,用于指定个别档案的变数。 Page Front-matter 用于页面配置Post Front-matter 用于文章页配置如果标注可选的参数,可根据自己需要添加,不用全部都写 Page...