Python simple code use `for..else` and not slow

  • 0
    class Solution(object):
        def searchInsert(self, nums, target):
            :type nums: List[int]
            :type target: int
            :rtype: int
            for i, num in enumerate(nums):
                if num >= target:
                    return i
                return i+1

Log in to reply

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