05 2022 档案

摘要:62. 丑数 class Solution { public: int getUglyNumber(int n) { vector<int> q(1, 1); int i = 0, j = 0, k = 0; while( -- n) // 循环 n - 1 次 { int t = min(q[i] 阅读全文
posted @ 2022-05-17 17:43 Tshaxz 阅读(23) 评论(0) 推荐(0) 编辑
摘要: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 阅读(23) 评论(0) 推荐(0) 编辑
摘要:求下一个序列的考虑方法: 尽量保证地位不变,变高位。所以可以从后往前去考虑 视频讲解:LeetCode 31. 下一个排列 模板题: 31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k 阅读全文
posted @ 2022-05-05 21:50 Tshaxz 阅读(57) 评论(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 阅读(42) 评论(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 阅读(38) 评论(0) 推荐(0) 编辑

Language: HTML
点击右上角即可分享
微信分享提示