摘要: ``` include include include // 时间复杂度是O(n), 空间复杂度O(n) using namespace std; class Solution1 { public: int longestConsecutive(const vector &nums) { unord 阅读全文
posted @ 2018-11-18 23:04 overfitover 阅读(104) 评论(0) 推荐(0) 编辑
摘要: ``` include include using namespace std; // 不是一直在查找中值,而是一直查找前k个值,每次去掉一部分值,k也相应减小,直到减到1为止,这样就可以算出结果 // time complexity O(log(m+n)) space complexity O(l 阅读全文
posted @ 2018-11-18 22:12 overfitover 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 1.暴力搜索时间复杂度O(n^2) include include include using namespace std; class Solution { public: vector twoSum(vector& nums, int target) { vector v(2, 0); // v 阅读全文
posted @ 2018-11-18 12:51 overfitover 阅读(127) 评论(0) 推荐(0) 编辑