Python 32 ms


  • 0
    R
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
    
        for i in range(len(nums)):
            if nums[i]==target:
                return i
            elif target<nums[i]:
                return i
        return len(nums)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.