Beats 100% Python submission


  • 2
    class Solution(object):
        def searchRange(self, nums, target):
            n = len(nums)
            left, right = -1, -1
            l, r = 0, n-1
            while l < r:
                m = (l+r)/2
                if nums[m] < target: l = m+1
                else: r = m
            if nums[l] != target: return -1, -1
            left = l
            l, r = left, n-1
            while l < r:
                m = (l+r)/2+1
                if nums[m] == target: l = m
                else: r = m-1
            right = l
            return left, right
    

    0_1473134524961_Screen Shot 2016-09-05 at 11.58.29 PM.png


  • 0
    S

    hahaha we trust you...


Log in to reply
 

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