Python | Leetcode Python题解之第540题有序数组中的单一元素
题目:
题解:
class Solution:def singleNonDuplicate(self, nums: List[int]) -> int:low, high = 0, len(nums) - 1while low < high:mid = (low + high) // 2mid -= mid & 1if nums[mid] == nums[mid + 1]:low = mid + 2else:high = midreturn nums[low]