Day 1 of 30-Day LeetCode Challenge

Aanchal Patial
1 min readApr 14, 2020

Given a non-empty array of integers, every element appears twice except for one. Find that single one.

class Solution {
public:
int singleNumber(vector<int>& nums) {
int result = nums[0];
for(int i=1;i<nums.size();++i){
result ^= nums[i];
}
return result;
}
};

--

--

Aanchal Patial

We never really grow up, we only learn how to act in public