Easy 5 line Solution JAVA 100 % beats 0ms
Intuition\nonly odd number of elements will contain 1 non duplicate elment\n# Approach\nmove towards the segment which has odd number of elements \n\n//checking
# Intuition\nonly odd number of elements will contain 1 non duplicate elment\n# Approach\nmove towards the segment which has odd number of elements \n```\n//checking for odd sequence\n        if((high+1-mid)%2!=0)  return solve(low,mid,nums);\n//checking for odd sequence\n        if((high+1-mid+1)%2!=0) return solve(mid+1,high,nums);\n```\nand try to check if true then increamment mid so that we end up having non duplicate on the left segment.\n``` if(nums[mid]==nums[mid+1]) mid++;```\n\n# Complexity\n- Time complexity:\n0ms 100% beats\n\n# Code\n```\nclass Solution {\n    int solve(int low,int high,int[] nums)\n    {\n        int mid=(low+high)/2; \n// special condition sometimes occurs while serching for duplicate\n //and it contains non duplicate value thus returning it as well\n        if(high==low)return nums[low];\n        if(nums[mid]==nums[mid+1]) mid++;\n//stoppping the recursion  at 3 elements and it is obvious that \n // 1 element will be non duplicate among 3 elemnts thus returning it\n        if(high-low==2) return(nums[high]^nums[mid]^nums[low]);\n//checking for odd sequence\n        if((high+1-mid)%2!=0)  return solve(low,mid,nums);\n//checking for odd sequence\n        if((high+1-mid+1)%2!=0) return solve(mid+1,high,nums);\n        return -1;\n    }\n    public int singleNonDuplicate(int[] nums) {\n        return solve(0,nums.length-1,nums);\n    }\n}\n```
['Binary Search', 'Java']