会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
穿过雾的阴霾
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
···
20
下一页
2023年7月4日
LeetCode 148. 排序链表
摘要: ``` class Solution { public: ListNode* sortList(ListNode* head) { if(!head||!head->next) return head; ListNode* fast=head,*slow=head; while(fast->next
阅读全文
posted @ 2023-07-04 00:24 穿过雾的阴霾
阅读(18)
评论(0)
推荐(0)
2023年7月3日
LeetCode 146. LRU缓存机制
摘要: ``` class LRUCache { public: struct node { int key,val; node *l,*r; node(int a,int b) { l=r=NULL; key=a; val=b; } }*L,*R; unordered_map mp;//保存key和节点的
阅读全文
posted @ 2023-07-03 15:26 穿过雾的阴霾
阅读(16)
评论(0)
推荐(0)
2023年7月1日
LeetCode 142. 环形链表 II
摘要: ``` /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class
阅读全文
posted @ 2023-07-01 10:30 穿过雾的阴霾
阅读(10)
评论(0)
推荐(0)
2023年6月30日
LeetCode 141. 环形链表
摘要: #取巧 ``` class Solution { public: const int INF=1e9; bool hasCycle(ListNode *head) { bool res=false; auto p=head; while(p) { if(p->val==INF) { res=true
阅读全文
posted @ 2023-06-30 16:41 穿过雾的阴霾
阅读(12)
评论(0)
推荐(0)
LeetCode 136. 只出现一次的数字
摘要: ``` class Solution { public: int singleNumber(vector& nums) { int res=0; for(auto i:nums) res^=i; return res; } }; ```
阅读全文
posted @ 2023-06-30 16:09 穿过雾的阴霾
阅读(19)
评论(0)
推荐(0)
2023年6月26日
LeetCode 128. 最长连续序列
摘要: * 为什么这题我都不会,脑袋有点累,状态真差 ``` class Solution { public: int longestConsecutive(vector& nums) { unordered_set s(nums.begin(),nums.end());//记录数字是否出现过 int re
阅读全文
posted @ 2023-06-26 15:05 穿过雾的阴霾
阅读(11)
评论(0)
推荐(0)
2023年6月13日
52. N 皇后 II
摘要: ``` class Solution { public: vector row,anti_diag,col,diag; int res=0; void dfs(int n,int x,int y,int cnt) { if(y==n) y=0,x++; if(x==n) { if(cnt==n) r
阅读全文
posted @ 2023-06-13 10:11 穿过雾的阴霾
阅读(15)
评论(0)
推荐(0)
LeetCode 51. N 皇后
摘要: ``` class Solution { public: vector> res; vector path; vector anti_diag,col,diag; void dfs(int n,int u) { if(u==n) { res.push_back(path); return; } st
阅读全文
posted @ 2023-06-13 09:51 穿过雾的阴霾
阅读(11)
评论(0)
推荐(0)
2023年6月12日
LeetCode 93. 复原IP地址
摘要: ``` class Solution { public: vector res; void dfs(string s,string path,int idx,int cnt)//枚举下一个逗号填哪 { if(idx>=s.size()) { if(idx==s.size()&&cnt==4) { p
阅读全文
posted @ 2023-06-12 10:26 穿过雾的阴霾
阅读(13)
评论(0)
推荐(0)
2023年6月11日
LeetCode 491. 递增子序列
摘要: ``` class Solution { public: vector> ans; vector path; void dfs(vector nums,int idx)//选择path的下一个数填什么,从下标idx开始选 { if(path.size()>=2) ans.push_back(path
阅读全文
posted @ 2023-06-11 11:28 穿过雾的阴霾
阅读(14)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
···
20
下一页
公告