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]
阅读全文
摘要:122. 糖果传递 写法一: #include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; L
阅读全文
摘要:求下一个序列的考虑方法: 尽量保证地位不变,变高位。所以可以从后往前去考虑 视频讲解:LeetCode 31. 下一个排列 模板题: 31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k
阅读全文
摘要:map按value排序/自定义排序规则 不能直接排,需要把map放入到vector中再对vector排序 方法如下 using PSI = pair<string, int>; vector<PSI> arr; unordered_map<string, int> mp
阅读全文
摘要:1346. 回文平方 进位制、双指针判断回文数 #include <iostream> #include <algorithm> #include <cstring> using namespace std; char get(int x) // 将x转化为b进制 { if(x <= 9) retu
阅读全文