Simple self-explanatory Python code

  • 0
    def search_range(nums, target):
        l, r = bisect.bisect_left(nums, target), bisect.bisect_right(nums, target)
        if l >= len(nums) or (l == 0 and nums[0] != target) or nums[l] != target:
            return [-1, -1]
        return [l, r - 1]

Log in to reply

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