# Isn't the time complexity of my solution O(log(n))?

class Solution:
# @param A : tuple of integers
# @param B : integer
# @return a list of integers
def first_occurrence(self,A,ele):
first=-1
start=0
end=len(A)-1

``````    while(start<=end):
mid = int((start + end) / 2)
if A[mid]<ele:
if A[mid+1]==ele:
first=mid+1
return first
else:
start=mid+1
elif A[mid]==ele:
if mid==0:
first=mid
return first
elif A[mid-1]<ele :
first=mid
return first
else:
end=mid-1
else:
end=mid-1
return first
def last_occurrence(self,A,ele):
last=-1
start=0
end=len(A)-1
while (start<=end):
mid=int((start+end)/2)
if A[mid]>ele:
if A[mid-1]==ele:
last=mid-1
return last
else:
end=mid-1
elif A[mid]==ele:
if mid==end:
last=mid
return last
elif A[mid+1]>ele:
last=mid
return last
else:
start=mid+1
else:
start=mid+1
return last
def searchRange(self, A, B):
A=list(A)

if len(A)==1:
if A[0]==B:
return [0,0]
else:
return [-1,-1]
else:
first=self.first_occurrence(A,B)
last=self.last_occurrence(A,B)
return [first,last]``````