Java Binary Search, O(log n) solution
\nclass Solution {\n    public int singleNonDuplicate(int[] nums) {\n        int start = 0;\n        int end = nums.length-1;\n        \n        if(nums.length 
```\nclass Solution {\n    public int singleNonDuplicate(int[] nums) {\n        int start = 0;\n        int end = nums.length-1;\n        \n        if(nums.length == 0) return 0;\n        else if(nums.length ==1) return nums[0];\n        else if(nums[0] != nums[1]) return nums[0];\n        else if(nums[end] != nums[end-1]) return nums[end];\n        \n        while(start <= end) {\n            int mid = start + (end - start) / 2;\n            \n            if(nums[mid] != nums[mid-1] && nums[mid] != nums[mid+1]) return nums[mid];\n            \n            else if(mid % 2 == 0) {\n                if(nums[mid] == nums[mid+1]) start = mid + 1;\n                else end = mid - 1;\n            }\n            else if(mid % 2 != 0) {\n                if(nums[mid] == nums[mid-1]) start = mid +1;\n                else end = mid - 1;\n            }   \n        }return -1;\n    }\n}\n```
['Binary Search', 'Java']