Golang | Leetcode Golang题解之第540题有序数组中的单一元素
题目:
题解:
func singleNonDuplicate(nums []int) int {low, high := 0, len(nums)-1for low < high {mid := low + (high-low)/2mid -= mid & 1if nums[mid] == nums[mid+1] {low = mid + 2} else {high = mid}}return nums[low]
}