上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页
摘要: /** 可看做26进制到10进制转换问题:v=26*v+s[i]-'A'; **/ class Solution { public: int titleToNumber(string s) { int v=0; for(char a:s){ v=26*v-'A'+a+1; } return v;... 阅读全文
posted @ 2019-05-28 17:24 Joel_Wang 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 对数算法:O(nlogn) 阅读全文
posted @ 2019-05-28 17:15 Joel_Wang 阅读(149) 评论(0) 推荐(0) 编辑
摘要: to_string(x) 将数字x转化为string atoi(x) 将char转化为int stoi(x) 将string 转化为int 采用中序遍历的顺序存储,NULL用#表示,以,分隔,O(n)time O(n) space 采用层序遍历的顺序,储存每一层的值,不存在的或者NULL值用#代替, 阅读全文
posted @ 2019-05-28 16:39 Joel_Wang 阅读(539) 评论(0) 推荐(0) 编辑
摘要: /** 验证一般情况(元素数目大于等于3)有几个情况分析:两个特殊情况: 6 5 4 3 2 1 完全反序,这种序列没有下一个排序,因此重新排序1 2 3 4 5 6 1 2 3 4 5 6 完全升序,很容易看出翻转5 6得到下一个排序; 因此对于以下一般情况有: 1 2 6 5 4 3 找到右边第一个a[i]& nums) { int len=nums.size(); ... 阅读全文
posted @ 2019-05-28 11:41 Joel_Wang 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 暴力解法:O(n) 想办法用二分查找Ologn 阅读全文
posted @ 2019-05-27 22:32 Joel_Wang 阅读(128) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: static bool cmp(vector a,vector b){ return a[0]> merge(vector>& intervals) { vector> res; sort(intervals.begin(),intervals.end(),cmp);... 阅读全文
posted @ 2019-05-27 22:26 Joel_Wang 阅读(181) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector searchRange(vector& nums, int target) { vector res(2,-1); int left=0;int right=nums.size()-1; if(right<0) return res; if(right==0)... 阅读全文
posted @ 2019-05-27 21:58 Joel_Wang 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 通过hash map遍历一遍存储出现的次数,通过小顶堆存储k个元素 阅读全文
posted @ 2019-05-27 20:24 Joel_Wang 阅读(217) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/fzuljz/p/6171963.html 阅读全文
posted @ 2019-05-27 19:52 Joel_Wang 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 两趟扫描,由于排序变量的特殊性,使用计数排序方法可以明显降低至O(n)time O(n) space 关于计数排序:https://mp.weixin.qq.com/s/WGqndkwLlzyVOHOdGK7X4Q 使用3个变量一趟扫描O(1) space O(n) time 具体实现过程参见:ht 阅读全文
posted @ 2019-05-27 16:13 Joel_Wang 阅读(195) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页