Simple C++ code in log(n) complexity
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int singleNonDuplicate(vector<int>& nums) {\n        int n=nums.size(),l=0,r=n-1,m;\n            while(l<r){\n            m=l+(r-l)/2;\n            if(m%2==0){\n                if(nums[m]==nums[m+1]) l=m+1;\n                else {r=m;} }\n            else{\n                if(nums[m]!=nums[m+1]) l=m+1;\n                else {r=m;}\n            }\n            }\n            return nums[l];\n    }\n};\n```
['C++']