随笔分类 -  哈希

摘要:题目来源 460. LFU 缓存 题目描述 请你为 最不经常使用(LFU)缓存算法设计并实现数据结构。 实现 LFUCache 类: LFUCache(int capacity) - 用数据结构的容量 capacity 初始化对象 int get(int key) - 如果键 key 存在于缓存中, 阅读全文
posted @ 2022-03-01 11:26 Garrett_Wale 阅读(46) 评论(0) 推荐(0) 编辑
摘要:题目来源 128. 最长连续序列 题目详情 给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度。 请你设计并实现时间复杂度为 O(n) 的算法解决此问题。 示例 1: 输入: nums = [100,4,200,1,3,2] 输出: 4 解释: 最长数 阅读全文
posted @ 2022-01-15 11:13 Garrett_Wale 阅读(401) 评论(0) 推荐(0) 编辑
摘要:1. 两数之和 LeetCode_1 题目描述 方法一:暴力法 package com.walegarrett.interview; /** * @Author WaleGarrett * @Date 2021/3/1 12:21 */ /** * 题目描述:给定一个整数数组 nums 和一个整数目 阅读全文
posted @ 2021-03-01 17:42 Garrett_Wale 阅读(114) 评论(0) 推荐(0) 编辑
摘要:题目来源 LeetCode-146 题目描述 实现 LRUCache 类: LRUCache(int capacity) 以 正整数 作为容量 capacity 初始化 LRU 缓存 int get(int key) 如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。 void 阅读全文
posted @ 2021-02-21 20:20 Garrett_Wale 阅读(72) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 53 - I. 在排序数组中查找数字 I Offer_53_1 题目描述 方法一:使用HashMap package com.walegarrett.offer; /** * @Author WaleGarrett * @Date 2021/2/9 20:10 */ import 阅读全文
posted @ 2021-02-09 20:32 Garrett_Wale 阅读(67) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 50. 第一个只出现一次的字符 Offer_50 题目详情 方法一:使用无序哈希表 package com.walegarrett.offer; /** * @Author WaleGarrett * @Date 2021/2/8 22:13 */ import java.util 阅读全文
posted @ 2021-02-09 09:12 Garrett_Wale 阅读(84) 评论(0) 推荐(0) 编辑
摘要:剑指 Offer 35. 复杂链表的复制 Offer_35 题目详情 方法一 可以使用一个HashMap来存储旧结点和新结点的映射。 这种方法需要遍历链表两遍,因为需要首先知道映射关系才能求出next和random结点。 package com.walegarrett.offer; import j 阅读全文
posted @ 2021-02-03 23:11 Garrett_Wale 阅读(45) 评论(0) 推荐(0) 编辑
摘要:Hashing - Average Search Time PAT-1145 需要注意本题的table的容量设置 二次探测,只考虑正增量 这里计算平均查找长度的方法和书本中的不同 #include<iostream> #include<cstring> #include<string> #inclu 阅读全文
posted @ 2020-09-20 20:20 Garrett_Wale 阅读(307) 评论(0) 推荐(0) 编辑
摘要:在受污染的二叉树中查找元素 "LeetCode 1261" 阅读全文
posted @ 2020-02-25 22:27 Garrett_Wale 阅读(172) 评论(0) 推荐(0) 编辑
摘要:宝石与石头 "LeetCode 771" 使用哈希表。 这里使用内置算法库中的map 阅读全文
posted @ 2020-02-25 20:18 Garrett_Wale 阅读(126) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示