Simple Python 6 line Code O(log(n)) Solution using bisect


#1
import bisect
class Solution:
# @param A : tuple of integers
# @param B : integer
# @return a list of integers
def searchRange(self, l, k):
    if k<l[0] or k>l[-1]:
        return [-1,-1]
    i=bisect.bisect_left(l,k)
    if l[i]!=k:
        return [-1,-1]
    return [i,bisect.bisect_right(l,k)-1]