Serenity

热爱可抵岁月漫长

一个热爱技术、喜欢折腾的开发者。 专注于前端开发,偶尔写写后端。 记录生活,分享技术,探索未知。

点击任意处进入哦~
加载中
输入关键词开始搜索
leetcode146. LRU 缓存

leetcode146. LRU 缓存

题目 题解 class LRUCache { private: int capacity; list<pair<int,int>>cache; unordered_map<int,list<pair<int,int>>::iterator> mp; public: L

leetcode
9月 Serenity
acwing2058. 笨拙的手指

acwing2058. 笨拙的手指

题目奶牛贝茜正在学习如何在不同进制之间转换数字。但是她总是犯错误,因为她无法轻易的用两个前蹄握住笔。每当贝茜将数字转换为一个新的进制并写下结果时,她总是将其中的某一位数字写错。例如,如果她将数字 14转换为二进制数,那么正确的结果应为 1110,但她可能会写下 0110或 1111。贝茜不会额外添加

acwing
2月 Serenity
acwing1221. 四平方和

acwing1221. 四平方和

暂无摘要...

acwing
11月 Serenity
leetcode205. 同构字符串

leetcode205. 同构字符串

暂无摘要...

leetcode
4月 Serenity
leetcode187. 重复的DNA序列

leetcode187. 重复的DNA序列

暂无摘要...

leetcode
3月 Serenity
leetcode133. 克隆图

leetcode133. 克隆图

class Solution {public: unordered_map&lt;Node*,Node*&gt;mp; Node* cloneGraph(Node* node) { if(!node)return nullptr; if(mp.find(nod

leetcode
3月 Serenity
leetcode49. 字母异位词分组

leetcode49. 字母异位词分组

分析string排序后的值相同的,可以使用字符串哈希将对应的字符串加进vector中,最后遍历哈希表,得到答案class Solution {public: vector&lt;vector&lt;string&gt;&gt; groupAnagrams(vector&lt;string&gt

leetcode
2月 Serenity
leetcode41. 缺失的第一个正数

leetcode41. 缺失的第一个正数

思路nums中有n个数,若nums中依次为1-n,则缺失的数为n+1,若其中有重复或者负数,那么这个缺失的数必在1-n中。则可以用nums这个数组作为哈希地址,由于存在重复数字,我们可以每次取nums[i]的绝对值,然后将其对应的nums的角标位置变成负数,最后遍历nums,找到第一个正数,其下标则

leetcode
1月 Serenity
acwing840. 模拟散列表

acwing840. 模拟散列表

拉链法#include&lt;iostream&gt;#include&lt;cstring&gt;using namespace std;const int N=100003;int e[N],ne[N],h[N],idx;void insert(int x){ int k=(x%N+N)%

acwing
1月 Serenity
acwing841. 字符串哈希

acwing841. 字符串哈希

给定一个长度为 n 的字符串,再给定 m 个询问,每个询问包含四个整数 l1,r1,l2,r2,请你判断 [l1,r1] 和 [l2,r2] 这两个区间所包含的字符串子串是否完全相同。字符串中只包含大小写英文字母和数字。输入格式第一行包含整数 n 和 m,表示字符串长度和询问次数。第二行包含一个长度

acwing
4月 Serenity