文章目录


数据结构算法操作试题(C++/Python):数据结构算法操作试题(C++/Python)——目录


1. 题目

leetcode 链接:https://leetcode-cn.com/problems/search-insert-position/
数据结构算法操作试题(C++/Python)——搜索插入位置

2. 解答

python:24ms, 10.9MB, 99%

class Solution(object):
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        i = -1
        for i in range(len(nums)):
            if nums[i] >= target: return i
        return i + 1

其他方法看 leetcode 链接 评论区~

相关文章:

  • 2021-12-01
  • 2021-08-18
  • 2022-12-23
  • 2021-08-26
  • 2021-06-22
  • 2021-07-08
猜你喜欢
  • 2021-08-15
  • 2021-09-17
  • 2022-01-23
  • 2021-11-16
  • 2021-10-03
  • 2021-09-20
相关资源
相似解决方案