python 2-line solution, o(lgn), 39ms

  • 0
    class Solution(object):
        def searchRange(self, nums, target):
            :type nums: List[int]
            :type target: int
            :rtype: List[int]
            s, e = bisect.bisect_left(nums, target), bisect.bisect_left(nums, target + 1) - 1
            return [-1, -1] if s > e else [s, e]

Log in to reply

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