Python short and clean. Binary Search.
Approach\n1. Since nums is sorted and it is guaranteed that all but one number occurs exactly twice. We can binary search for the number with no pair.\n\n2. Say
# Approach\n1. Since `nums` is sorted and it is guaranteed that all but one number occurs exactly twice. We can binary search for the number with no pair.\n\n2. Say `m` is the mid point in the search and if all numbers had pairs,\n    If `m` is even index, the repeating pair should be at `m + 1`.\n    If `m` is odd index, the repeating pair should be at `m - 1`.\n    Let\'s call them `i, j = (m - 1, m) if m % 2 else (m, m + 1)`\n\n3. Now, if `nums[i] == nums[j]` we know all numbers to the left of `j` has a pair. Hence Binary Search on the right sub array.\n    If `nums[i] != nums[j]` we know the additional number is to the left of `j`. Hence Binary Search on the left sub array.\n\n4. Return when `i == j`.\n\n# Complexity\n- Time complexity: $$O(log(n))$$\n\n- Space complexity: $$O(1)$$\n\nwhere, `n is the length of nums`.\n\n# Code\n```\nclass Solution:\n    def singleNonDuplicate(self, nums: list[int]) -> int:\n        l, r = 0, len(nums) - 1\n        while l < r:\n            m = (l + r) // 2\n            i, j = (m - 1, m) if m % 2 else (m, m + 1)\n            l, r = (j + 1, r) if nums[i] == nums[j] else (l, i)\n        return nums[r]\n\n\n```
['Array', 'Math', 'Python', 'Python3']