05 2022 档案

摘要:计算两个日期的间隔是否是一天 datediff(w1.recordDate,w2.recordDate)=1 {"headers": ["id"], "values": [[678], [446], [517], [955], [1007], [329], [603], [798], [812], 阅读全文
posted @ 2022-05-22 18:24 智人心 阅读(22) 评论(0) 推荐(0) 编辑
摘要:count自增的方法: let count = $count+1 阅读全文
posted @ 2022-05-22 17:39 智人心 阅读(14) 评论(0) 推荐(0) 编辑
摘要:队列的最后进入的元素q.back() /* // Definition for a Node. class Node { public: int val; vector<Node*> children; Node() {} Node(int _val) { val = _val; } Node(in 阅读全文
posted @ 2022-05-21 14:57 智人心 阅读(19) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int findLUSlength(string a, string b) { if(a==b)return -1; return max(a.size(),b.size()); } }; 有点无语 阅读全文
posted @ 2022-05-21 10:36 智人心 阅读(12) 评论(0) 推荐(0) 编辑
摘要:令队列一为主队列,队列二为辅助队列 当队列一空的时候,输入的元素直接放进来,即队头和队尾都是这个元素 当队列非空的时候,输入一个元素: 先把队列一的元素都放入队列二,输入此元素,再把队列二倒入队列一,这样就实现了新入队的元素在队列一的头,即后进先出 另外,queue<int>q的基本操作是: q.f 阅读全文
posted @ 2022-05-20 19:11 智人心 阅读(10) 评论(0) 推荐(0) 编辑
摘要:思路:分而治之 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullp 阅读全文
posted @ 2022-05-20 18:04 智人心 阅读(15) 评论(0) 推荐(0) 编辑
摘要:思路:由题意,若操作中有1出现返回true,若105次无1出现,返回false,至于105可以理解为取遍100以内的数的循环次数 阅读全文
posted @ 2022-05-20 17:49 智人心 阅读(16) 评论(0) 推荐(0) 编辑
摘要:巴什博奕,n%(m+1)!=0时,先手总是会赢的 如果n是4的倍数,无论怎么拿都输;反之,可以拿去相应的石子让对手面对4的倍数 阅读全文
posted @ 2022-05-20 16:03 智人心 阅读(20) 评论(0) 推荐(0) 编辑
摘要:注意二叉树的深度遍历即先序、中序、后序遍历之一,sprintf中char c[n]的长度包括'\0'即数字的长度+1,在数字是-100时最长,长度为4+1即5,char c[4]会溢出 /** * Definition for a binary tree node. * struct TreeNod 阅读全文
posted @ 2022-05-20 15:44 智人心 阅读(17) 评论(0) 推荐(0) 编辑
摘要:利用到了并查集相关的知识,贴出压缩路径,按秩合并的代码 https://blog.csdn.net/weixin_38279101/article/details/112546053 //并查集类 class DisJointSetUnion { private: // 所有根结点相同的结点位于同一 阅读全文
posted @ 2022-05-20 13:25 智人心 阅读(59) 评论(0) 推荐(0) 编辑
摘要:虽然过了,但是还是不是很清楚,中序遍历,访问每个非空节点时,将左指针置空,pre记录每个父节点,父节点的right置为当前节点 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *le 阅读全文
posted @ 2022-05-18 21:16 智人心 阅读(29) 评论(0) 推荐(0) 编辑
摘要:目前只能暴破,应该有更高效的算法 阅读全文
posted @ 2022-05-13 20:22 智人心 阅读(3) 评论(0) 推荐(0) 编辑
摘要:char转string的时候注意char数组的最后一个字符要是'\0' 阅读全文
posted @ 2022-05-13 20:10 智人心 阅读(19) 评论(0) 推荐(0) 编辑
摘要:set的添加: set<string>s; s.insert("abc"); 阅读全文
posted @ 2022-05-13 19:52 智人心 阅读(17) 评论(0) 推荐(0) 编辑
摘要:注意仅有一个字符不相等是false 阅读全文
posted @ 2022-05-13 14:55 智人心 阅读(18) 评论(0) 推荐(0) 编辑
摘要:注意 1: left join 用的是on而不是where 2: 如果空则赋0 ifnull(sum(r.distance,0) select u.name name,ifnull(sum(r.distance),0) travelled_distance from Users u left joi 阅读全文
posted @ 2022-05-13 13:44 智人心 阅读(27) 评论(0) 推荐(0) 编辑
摘要:利用unordered_map<int,int>hashmap可以将查找的时间缩小至O(1) class Solution { public: vector<int> arrayRankTransform(vector<int>& arr) { int n = arr.size(),MIN,MINP 阅读全文
posted @ 2022-05-13 09:04 智人心 阅读(13) 评论(0) 推荐(0) 编辑
摘要:没办法,背下来吧 import java.text.*; import java.util.*; import java.lang.*; class Solution { public int daysBetweenDates(String date1, String date2){ int day 阅读全文
posted @ 2022-05-12 21:44 智人心 阅读(15) 评论(0) 推荐(0) 编辑
摘要:char数组转string 方法1: string str(ch); 方法2: string str = ch; 方法3(对string进一步操作): string s0 = ch; string s3 (s0, 8, 3); 阅读全文
posted @ 2022-05-12 21:13 智人心 阅读(18) 评论(0) 推荐(0) 编辑
摘要:判断两个矩形的边所在直线关系即可 class Solution { public: bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) { return !(rec1[0]>=rec2[2]||rec1[2]<=rec2[0]| 阅读全文
posted @ 2022-05-12 19:25 智人心 阅读(16) 评论(0) 推荐(0) 编辑
摘要:map<string,int>的用法 map<string,int>mp; mp["abc"]++; 阅读全文
posted @ 2022-05-12 14:05 智人心 阅读(20) 评论(0) 推荐(0) 编辑
摘要:三角形面积计算公式: 参考 https://baike.baidu.com/item/%E4%B8%89%E8%A7%92%E5%BD%A2%E9%9D%A2%E7%A7%AF%E5%85%AC%E5%BC%8F/8491990 阅读全文
posted @ 2022-05-12 12:47 智人心 阅读(45) 评论(0) 推荐(0) 编辑
摘要:set的添加: set<string>wSet; string s = "sss"; wSet.insert(s); 遍历: for (auto it = wSet.cbegin(); it != wSet.cend(); it++){ cout<<*it<<endl; } 删除: wSet.era 阅读全文
posted @ 2022-05-12 12:21 智人心 阅读(24) 评论(0) 推荐(0) 编辑
摘要:巧妙的转化思想: n-1个数都加1相当于最大数减1 结果就是每个数减去最小数差的总和 阅读全文
posted @ 2022-05-10 14:45 智人心 阅读(14) 评论(0) 推荐(0) 编辑
摘要:注意两点: 1.int转化成string: int start; stringstream ss; string s; ss<<start; s = ss.str(); 2.stringstream的清空操作: ss.str(""); 注: 据说 ss.clear(); //clear flags. 阅读全文
posted @ 2022-05-10 14:14 智人心 阅读(15) 评论(0) 推荐(0) 编辑
摘要:注意变量的类型 class Solution { public: uint32_t reverseBits(uint32_t n) { uint32_t result = 0,a[32],j; int i; for(i=0;i<32;i++){ a[i] = n%2; n /= 2; } for(i 阅读全文
posted @ 2022-05-10 13:43 智人心 阅读(14) 评论(0) 推荐(0) 编辑
摘要:先在m*n矩阵中匹配word[0]和board[i][j] 如果匹配成功让word的子序列(除去word[0])进入dfs回溯法 在dfs中每次比较四周字符与word[0],如果匹配成功,再令word的子序列进入dfs直至word序列为空返回true 如果某次匹配不成功,则回溯,将相应flag标记置 阅读全文
posted @ 2022-05-10 11:11 智人心 阅读(17) 评论(0) 推荐(0) 编辑
摘要:v初始化为只有空集的vector 遍历nums容器中的元素,每次扩容v为原先的两倍并将后一半子集每个都加上nums[i] 阅读全文
posted @ 2022-05-10 10:16 智人心 阅读(15) 评论(0) 推荐(0) 编辑
摘要:kase从1开始自增,n每次减去kase,当n减到负数的时候,kase-2即为所求 阅读全文
posted @ 2022-05-10 09:35 智人心 阅读(4) 评论(0) 推荐(0) 编辑
摘要:利用二进制数的特性,每逢2的幂1的个数退回1,并且与之前的计算有着差1的关系,即: a[i] = a[i-kase/2]+1; 阅读全文
posted @ 2022-05-09 20:15 智人心 阅读(14) 评论(0) 推荐(0) 编辑
摘要:令min = 0,max = n, 从0到n-1扫描s,如果s[i]是I就令结果vector添加一个元素min并令min++ 如果s[i]是D就令结果vector添加一个元素max并令max-- 最后添加一个元素min或者max(min==max) 阅读全文
posted @ 2022-05-09 19:36 智人心 阅读(16) 评论(0) 推荐(0) 编辑

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