8 lines Python code, 42ms


  • 1
    A
    class Solution(object):
        def searchRange(self, nums, target):
            try:
                begin_p = nums.index(target)
                end_p = begin_p + nums.count(target) - 1
                return [begin_p, end_p]
            except:
                return [-1, -1]
    

Log in to reply
 

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