Leetcode 136 Solution

This article provides solution to leetcode question 136 (single-number).

https://leetcode.com/problems/single-number

Solution

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int x = 0;
        
        for (auto it = nums.begin(); it != nums.end(); it++)
        {
            x ^= *it;
        }
        
        return x;
    }
};