35. Search Insert Position
Input: [1,3,5,6], 5
Output: 2Input: [1,3,5,6], 2
Output: 1Input: [1,3,5,6], 7
Output: 4Input: [1,3,5,6], 0
Output: 0class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
i = 0
while i < len(nums):
if nums[i] >= target:
break
i += 1
return iLast updated