Easy-to-understand python solution


  • 0
    import bisect
    class Solution(object):
        def searchRange(self, nums, target):
            start = bisect.bisect_left(nums, target)
            if 0<=start<len(nums):
                end = bisect.bisect_right(nums, target)
                if end-1>=start:
                    return [start, end-1]
            return [-1, -1]
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.