C++ Solution with step by step explanation.
Attacking the problem\nYou start with B.S. as the question is tagged as B.S. and then think that the array is sorted so B.S. it is.\nStuck!! How do I know if I 
**Attacking the problem**\nYou start with B.S. as the question is tagged as B.S. and then think that the array is sorted so B.S. it is.\n**Stuck!! How do I know if I go left or right from the middle :(**\nOkay jokes apart this is a really good problem on B.S. and let us carefully analyse what we are given.\nThe array is sorted and as only one unique element and other elements exist as pairs. \nDIY take few example arrays and write the indices above all the elements. \n**Observe** \nGot something?\nNo?\n**Observe again and look at the indices of pairs on the left of the unique element and on the right of the unique element**\n\nWe see that for every case on the left of the unique element the pairs exist as (even,odd), (even,odd),......(even)\nwhere singular (even) is the index of the unique element. \n(It can be easily concluded that the index of the unique element will always be even.)\nAfter the unique element the pairs on the right exist as (odd,even),(odd,even),........\nSo are we still stuck on where to go, left or right? \nBy seeing this pattern we have found two distinct search spaces and we can move towards the unique element by checking in which search space we are in.\nIf we are in the left search space we go right.\nIf we are in the right search space we go left.\nI leave the code for your reference below. \n\n```\nint singleNonDuplicate(vector<int>& nums) {\n        if(nums.size()==1)\n            return nums[0];\n        int l = 0,r=nums.size()-1;\n        while(l<=r){\n            int m = l + (r-l)/2;\n            if(m%2){\n\t\t\t\t// (even odd) i.e. we are on the left side of unique element--> go right\n                if(nums[m-1]==nums[m])\n                    l = m+1;\n\t\t\t\t// (even odd) pair violated, happens on the right side of unique element--> go left\n                else{\n                    r = m-1;\n                }\n            }else{\n\t\t\t\t// (even odd) i.e. we are on the left side of unique element--> go right\n                if(nums[m]==nums[m+1]){\n                    l = m+1;\n\t\t\t\t// (even odd) pair violated, happens on the right side of unique element--> go left\n                }else{\n                    r = m-1;\n                }\n            }\n        }\n        return nums[l];\n    }\n```
['C', 'Binary Tree']