Three-line Python, Crystal Clear!

  • 0
    class Solution(object):
        def searchInsert(self, nums, target):
            for index,item in enumerate(nums):
                if target <= item: return index
                elif index == len(nums) - 1: return index + 1

    Just Array

Log in to reply

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