Simple Binary Search Approach
Basic Idea: Find the number of element to the right of nums[m], and reduce search space according to it.\n\nclass Solution {\npublic:\n    int singleNonDuplicat
**Basic Idea:** Find the number of element to the right of nums[m], and reduce search space according to it.\n```\nclass Solution {\npublic:\n    int singleNonDuplicate(vector<int>& nums) {\n        \n        int l = 0;\n        int h  = nums.size() - 1;\n        \n        \n        while(l<h){\n            int m = l + (h-l)/2;\n            bool isEven = false;\n            \n            if((h-m)%2 == 0){\n                isEven = true; // there are even number of elements present in right side of nums[m]\n            }\n            else if((h-m)%2 == 1){\n                isEven = false; // there are odd number of elements present in right side of nums[m]\n            }\n            \n            if(nums[m] == nums[m+1]){\n                if(isEven){\n                    l = m + 2;\n                }else{\n                    h = m - 1;\n                }\n            }else{\n                if(isEven){\n                    h = m;\n                }else{\n                    l = m + 1;\n                }\n            }\n        }\n        return nums[l];\n    }\n};\n```
['Math', 'Binary Tree']