上一页 1 2 3 4 5 6 7 8 ··· 20 下一页
摘要: ``` 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)
摘要: ``` 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)
摘要: ``` /** * 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)
摘要: #取巧 ``` 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)
摘要: ``` 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)
摘要: * 为什么这题我都不会,脑袋有点累,状态真差 ``` 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)
摘要: ``` 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)
摘要: ``` 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)
摘要: ``` 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)
摘要: ``` 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 下一页