#pythoner , everyone is using BS or bisect but not me

from collections import Counter
def searchRange(self, A, B):
if B not in A:
return [-1,-1]
A = list(A)
C = Counter(A)
key = C.keys()
value = C.values()
c_index = key.index(B)
a_index = A.index(B)
b_value = value[c_index]
if b_value>1:
return [a_index, a_index+b_value-1]
elif b_value==1:
return [a_index, a_index]

Please leave a comment if you like this method.

Its not O(log n). x in list and list.index(x) are both O(n).

Click here to start solving coding interview questions