Loading

摘要: 思路 方法一:二分 遍历每个数字num,然后再在后面的数字中使用二分查找target-num。 复杂度分析 时间复杂度:O(nlogn) 空间复杂度:O(1) 1 class Solution { 2 public: 3 vector<int> twoSum(vector<int>& nums, i 阅读全文
posted @ 2020-11-13 20:23 拾月凄辰 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 思路 方法:位运算 遍历统计 1 class Solution { 2 private: 3 int cnt[32] = {0}; 4 public: 5 int singleNumber(vector<int>& nums) { 6 for(int num: nums) { 7 for(int i 阅读全文
posted @ 2020-11-13 20:02 拾月凄辰 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 思路 方法:分组异或 1 class Solution { 2 public: 3 vector<int> singleNumbers(vector<int>& nums) { 4 int res = 0; 5 for(int &num: nums) { 6 res ^= num; 7 } 8 9 阅读全文
posted @ 2020-11-13 17:38 拾月凄辰 阅读(85) 评论(0) 推荐(0) 编辑