Last updated 2 years ago
class Solution: def searchInsert(self, nums: List[int], target: int) -> int: left = 0 right = len(nums) while left < right: mid = left + (right - left) // 2 if nums[mid] < target: left = mid + 1 elif nums[mid] >= target: right = mid return left