Single Number II (easy and intuitive solution)


#1

Comment body goes here.
int Solution::singleNumber(const vector &nums) {

int n=nums.size();
    vector<int> v=nums;
    sort(v.begin(),v.end());
    
    for(int i=0;i<n-2;i+=3){
        if(v[i]!=v[i+1])
            return v[i];
    }
    
    return v[n-1];

}


#2

well, It is asked to write linear time complexity algorithm but your sort function itself takes O(nlogn) time