= target。35.搜索插入位置-Python-Leetcode。" />

35.搜索插入位置-Python-Leetcode

题目来源 https://leetcode-cn.com/problems/search-insert-position/description/
代码

class Solution: def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ l = len(nums) flag = False if nums[0] >= target: return 0 if nums[l-1] < target: return lfor i in range(l): if target == nums[i]: return i elif target > nums[i]: flag = True elif target < nums[i]: while flag: return i

【35.搜索插入位置-Python-Leetcode】35.搜索插入位置-Python-Leetcode
文章图片

(这是一个数院的菜鸡

    推荐阅读