leetcode-算法-35

給定一個排序數組和一個目標值,在數組中找到目標值,並返回其索引。若是目標值不存在於數組中,返回它將會被按順序插入的位置。 你能夠假設數組中無重複元素。 這個代碼比較滿意,先插入,而後找。不管是否存在原數。python class Solution: def searchInsert(self, nums: List[int], target: int) -> int: n
相關文章
相關標籤/搜索