摘要: 暴力解法:O(n) 想办法用二分查找Ologn 阅读全文
posted @ 2019-05-27 22:32 Joel_Wang 阅读(131) 评论(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 阅读(189) 评论(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 阅读(276) 评论(0) 推荐(0)
摘要: 通过hash map遍历一遍存储出现的次数,通过小顶堆存储k个元素 阅读全文
posted @ 2019-05-27 20:24 Joel_Wang 阅读(226) 评论(0) 推荐(0)
摘要: https://www.cnblogs.com/fzuljz/p/6171963.html 阅读全文
posted @ 2019-05-27 19:52 Joel_Wang 阅读(139) 评论(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 阅读(210) 评论(0) 推荐(0)
摘要: O(m+n)time O(1)space算法: 阅读全文
posted @ 2019-05-27 12:00 Joel_Wang 阅读(198) 评论(0) 推荐(0)
摘要: //经过剪枝的全排列解算, /**** 1)左右括号都必须为n,即left<n,right<n; 2)必须先放置左括号才能放置右括号,即限制条件有left>right; ****/ 其中left,right分别为i,j DFS+剪枝: 阅读全文
posted @ 2019-05-27 10:45 Joel_Wang 阅读(184) 评论(0) 推荐(0)
摘要: 回溯法: 阅读全文
posted @ 2019-05-27 10:34 Joel_Wang 阅读(343) 评论(0) 推荐(0)