136. Single Number
problem description
Input: [2,2,1]
Output: 1Input: [4,1,2,1,2]
Output: 4algorithm thought
code
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res=0;
for(auto num:nums){
res^=num;
}
return res;
}
};algorithm analysis
Last updated