一拿到这题,想法很简单,要么二分要么利用index
index无脑解法:(效率还挺高)
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
if target not in nums:return [-1,-1]
a=nums.index(target)
b=nums[::-1].index(target)
return [a,len(nums)-1-b]
二分法:
暂时没有想出来.....