class Solution(object):
def searchInsert(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
if target in nums:
return nums.index(target)
else:
nums.append(target)
nums.sort()
return nums.index(target)```
LeetCode 35. 搜索插入位置
最新推荐文章于 2024-08-02 00:25:43 发布