上一页 1 ··· 6 7 8 9 10 11 12 下一页
摘要: 122. 糖果传递 写法一: #include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; L 阅读全文
posted @ 2022-05-10 13:45 Tshaxz 阅读(28) 评论(0) 推荐(0)
摘要: 求下一个序列的考虑方法: 尽量保证地位不变,变高位。所以可以从后往前去考虑 视频讲解:LeetCode 31. 下一个排列 模板题: 31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k 阅读全文
posted @ 2022-05-05 21:50 Tshaxz 阅读(65) 评论(0) 推荐(0)
摘要: map按value排序/自定义排序规则 \(sort\)不能直接排\(map\),需要把map放入到vector中再对vector排序 方法如下 using PSI = pair<string, int>; vector<PSI> arr; unordered_map<string, int> mp 阅读全文
posted @ 2022-05-04 18:18 Tshaxz 阅读(59) 评论(0) 推荐(0)
摘要: 1346. 回文平方 进位制、双指针判断回文数 #include <iostream> #include <algorithm> #include <cstring> using namespace std; char get(int x) // 将x转化为b进制 { if(x <= 9) retu 阅读全文
posted @ 2022-05-04 16:29 Tshaxz 阅读(42) 评论(0) 推荐(0)
摘要: 1346. 回文平方 #include <iostream> #include <algorithm> #include <cstring> using namespace std; char get(int x) // 将x转化为b进制 { if(x <= 9) return x + '0'; r 阅读全文
posted @ 2022-04-18 22:11 Tshaxz 阅读(30) 评论(0) 推荐(0)
摘要: 13. 找出数组中重复的数字 class Solution { public: int duplicateInArray(vector<int>& nums) { if(nums.empty()) return -1; unordered_map<int, int> hash; int n = nu 阅读全文
posted @ 2022-04-16 22:08 Tshaxz 阅读(21) 评论(0) 推荐(0)
摘要: AcWing PAT甲级树专题 1476. 数叶子结点 #include <iostream> #include <cstring> using namespace std; const int N = 110; int h[N], e[N], ne[N], idx; int n, m; int c 阅读全文
posted @ 2022-04-15 21:55 Tshaxz 阅读(54) 评论(0) 推荐(0)
摘要: 学习资料 1.单调栈知识 2.算法讲解052【必备】单调栈-上 口诀:大增小减,左从左到右,右从右到左 解释:找某个元素左边或右边第一个比它大的元素,构造单调递增栈,遍历顺序与前面左右相同,要找左边就从左到右遍历,要找右边就从右到左遍历; 找某个元素左边或右边第一个比它小的元素,构造单调递减栈,遍历 阅读全文
posted @ 2022-04-12 18:42 Tshaxz 阅读(56) 评论(0) 推荐(0)
摘要: 1byte = 8bit即1字节=8比特 1个int有4个byte,即32个bit 1个char有1个byte,即8个bit 1个long long有8个byte 1个float有4个byte 1个double有8个byte 题目中的空间限制如64MB,有$64 \times 2^{20} \app 阅读全文
posted @ 2021-10-03 10:09 Tshaxz 阅读(44) 评论(0) 推荐(0)
摘要: 一维差分 差分可以看成前缀和的逆运算 构造差分数组b[]的方法: 作用:可以在$O(1)$的时间给区间[l, r]内的数都加上一个数c 模板题:AcWing 797. 差分 #include <iostream> using namespace std; const int N = 1e5 + 10 阅读全文
posted @ 2021-09-12 17:21 Tshaxz 阅读(231) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 下一页
Language: HTML