classSolution { public: vector<int> singleNumber(vector<int>& nums){ int sum = 0; for (int i : nums) sum ^= i; int k = -1; for(int i = 31; i >= 0 && k == -1; i--) { if (((sum >> i) & 1) == 1) k = i; } vector<int> ans(2);
for (int i : nums) { if (((i >> k) & 1) == 1) ans[1] ^= i; else ans[0] ^= i; } return ans; } };