标签:sea find 一个 bsp 排序 sel tar def ast
1 class Solution: 2 def searchRange(self, nums: List[int], target: int) -> List[int]: 3 ans,lens = [-1,-1],len(nums) 4 left,right,flag = 0,lens - 1,True 5 while left <= right and flag: 6 mid = left + (right - left) // 2 7 if nums[mid] == target: 8 i = j = mid 9 while i >= 0 or j < lens: 10 if i >= 0 and nums[i] == target: 11 ans[0] = i 12 if j < lens and nums[j] == target: 13 ans[1] = j 14 i -= 1 15 j += 1 16 flag = False 17 elif nums[mid] > target: 18 right = mid - 1 19 else:left = mid + 1 20 return ans 21
标签:sea find 一个 bsp 排序 sel tar def ast
原文地址:https://www.cnblogs.com/lj95/p/14397913.html