Easy python solution code


#1

class Solution:
# @param A : tuple of integers
# @param B : integer
# @return a list of integers
def searchRange(self, A, B):
ans=[]
n=len(A)
if n==1:
if (B == A[0]):
ans.append(0)
ans.append(0)
else:
ans.append(-1)
ans.append(-1)
else:
try:
f=A.index(B)
ans.append(f)
p=f
while(A[p]==B):
#if p<n:
p=p+1
if p>=n:
break
ans.append(p-1)
except ValueError:
ans.append(-1)
ans.append(-1)
return ans