Java Super Elegent solution (log(n) Runtime O(1) extra space, bit trick). [Detailed explanation]
Idea behind the solution:\n\n1.  If the current index in the binary search is I (0 index based), the we can decide the next search space based on:\n\ta. If I is
Idea behind the solution:\n\n1.  If the current index in the binary search is `I` (0 index based), the we can decide the next search space based on:\n\ta. If `I` is even, and `nums[I] == nums[I + 1]`, then size of subarray `[0...I-1]` (left side) is even (since the element count is `I`), so left side does not contain the single occurance element. Hence we need to check in `[I + 1, ..., N]` subarray (right side of `I`)\n\tb. If `I` is odd, and `nums[I] == nums[I - 1]`, then size of subarray `[0...I-2]` (left side) is even (since the element count is `I - 1`, and `I-1` is even since `I` is odd), so left side does not contain the single occurance element. Hence we need to check in `[I + 1, ..., N]` subarray (right side of `I`) </br>\n\tNote: How can you implement the check operation. Remember the xor operation, and if you xor any number with 1, then it flips the LSB (Least significant bit)\nEx. 1) `100^1=101` [i.e `4^1=5`, flips the first bit from right side] </br> 2) `101^1=100` [i.e `5^1=4`, again flips the first bit from right side]\nSo, if  `I` is even, to find the next element we do `I^1`\n\tand if `I` is odd, to find the previous element we do `I^1`\n```\nclass Solution {\n    public int singleNonDuplicate(int[] nums) {\n        int l = 0;\n        int h = nums.length - 1;\n        while (l < h) {\n            int m = (l + h) / 2;\n            if (nums[m] == nums[m ^ 1]) {\n                l = m + 1;\n            } else {\n                h = m;\n            }\n        }\n        return nums[h];\n    }\n}\n```
['Binary Search', 'Java']