1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class Solution(object): def searchInsert(self, nums, target): k=0 s=0 for i in range(len(nums)): if nums[i]!=target: k+=1 else: return k for j in range(1,len(nums)): if nums[j-1] < target: if nums[j] > target: return j return(len(nums))
|