LeetCode--搜索插入位置(python版)

class Solution(object):
    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
            if nums[i]>target:
                return i
        return len(nums)

你可能感兴趣的:(LeetCode--搜索插入位置(python版))