上一页 1 2 3 4 5 6 ··· 20 下一页
摘要: ``` class Solution { public: struct node { int val; int pre; node* next; node(int a,int b,node* c) { val=a; pre=b; next=c; } }; void insert(node* &hea 阅读全文
posted @ 2023-07-25 11:24 穿过雾的阴霾 阅读(7) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector calcEquation(vector>& equations, vector& values, vector>& queries) { unordered_set node;//记录所有节点 unordered_map> g; 阅读全文
posted @ 2023-07-24 12:25 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: string dfs(string s,int &idx) { string str; while(idx'0'&&s[idx]='0'&&s[idx]<='9') num+=s[idx++]; if(s[idx]=='[') { int c 阅读全文
posted @ 2023-07-22 19:52 穿过雾的阴霾 阅读(3) 评论(0) 推荐(0) 编辑
摘要: # 快排思想 - 注意,这里是倒序排序,因此应该`while(nums[i].cnt>x);` ``` class Solution { public: struct element { int val,cnt; element(int a,int b) { val=a; cnt=b; } }; v 阅读全文
posted @ 2023-07-21 12:14 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector countBits(int n) { vector f(n+1); for(int i=1;i>1]+(i&1); return f; } }; ``` 阅读全文
posted @ 2023-07-20 23:13 穿过雾的阴霾 阅读(2) 评论(0) 推荐(0) 编辑
摘要: ## 思路 本题有两点需要解决,如果确定括号的最少删除数量以及删除哪些括号 #### 求出最少删除数量 思路见 LeetCode 22. 括号生成 #### 已知删除数量,删除哪些括号? 直接爆搜,枚举每个括号是否删除 - 如果当前是左括号,枚举是否删除 (删除 0 还是 1 个) - 如果当前是左 阅读全文
posted @ 2023-07-18 13:04 穿过雾的阴霾 阅读(56) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int findDuplicate(vector& nums) { if(nums.size()<2) return nums[0]; int n=nums.size(); int fast=0,slow=0; do { slow=nums[ 阅读全文
posted @ 2023-07-17 11:11 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: void moveZeroes(vector& nums) { if(nums.empty()) return; int n=nums.size(); int idx=n-1; while(idx>=0&&nums[idx]==0) idx- 阅读全文
posted @ 2023-07-15 09:30 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: bool searchMatrix(vector>& matrix, int target) { if(matrix.empty()||matrix[0].empty()) return false; int n=matrix.size(), 阅读全文
posted @ 2023-07-15 09:15 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector maxSlidingWindow(vector& nums, int k) { deque q; vector res; for(int i=0;i=k) q.pop_front(); //插入新元素 while(q.size( 阅读全文
posted @ 2023-07-14 12:53 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 20 下一页
点击右上角即可分享
微信分享提示