Skip to main content

136. Single Number

class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for (auto& num : nums)
res ^= num;
return res;
}
};
  • T: O(N)O(N)
  • S: O(1)O(1)