题目:35. Search Insert Position
问题描述:https://leetcode.com/problems/search-insert-position/description/
大致意思是说,在一个有序序列中寻找target的插入位置,若存在则返回其下标。
Python:
import bisect
class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
length=len(nums)
if length==0:
return 0
return bisect.bisect_left(nums,target)