一、只出现一次的数字
1 class Solution { 2 public: 3 int singleNumber(vector<int>& nums) 4 { 5 int res = 0; 6 for (auto num : nums) 7 res ^= num; 8 return res; 9 } 10 };
原文地址:https://www.cnblogs.com/sunbines/p/10585733.html
时间: 2024-10-18 10:01:18
1 class Solution { 2 public: 3 int singleNumber(vector<int>& nums) 4 { 5 int res = 0; 6 for (auto num : nums) 7 res ^= num; 8 return res; 9 } 10 };
原文地址:https://www.cnblogs.com/sunbines/p/10585733.html