260. Single Number III 發表於 2023-02-13 | 分類於 leetcode problemsolution1234567891011121314class Solution {public: vector<int> singleNumber(vector<int>& nums) { unsigned int diff = 0; for(int n:nums) diff^=n; diff &= (-diff); int a=0, b=0; for(int n:nums){ if(n&diff) a^= n; else b^=n; } return {a,b}; }}; analysis time complexity O(n) space complexity O(1)