classSolution(object):defsearchRange(self,nums,target):""" :type nums: List[int] :type target: int :rtype: List[int] """ifnotnums:return[-1,-1]ret=[-1,-1]start=0end=len(nums)-1whilestart<=end:mid=(start+end)/2iftarget==nums[mid]:breakeliftarget>nums[mid]:start=mid+1else:end=mid-1# Not foundifstart>end:returnretl=midr=mid# Find range whilel>0andnums[mid]==nums[l-1]:l-=1whiler<endandnums[mid]==nums[r+1]:r+=1return[l,r]