A Simple C++ Solution


  • 0
    R
    class Solution {
    public:
        int singleNonDuplicate(vector<int>& nums) {
            for (int i=0;i<nums.size()-2;i=i+2){
                if (nums[i]==nums[i+1]) continue;
                else return nums[i];
            }
            return nums[nums.size()-1];
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.