ID: 704; easy
func search(nums []int, target int) int { low, high := 0, len(nums) - 1 for low <= high { mid := (low + high) / 2 if nums[mid] == target { return mid } else if nums[mid] > target { high = mid - 1 } else { low = mid + 1 } } return -1 }
Last updated 3 years ago