Can anyone tell me that what is the complexity of this code. Problem Name: Maximum aera of histogram Question Link: https://leetcode.com/problems/largest-rectangle-in-histogram/
def MAH(self,arr: List):
n=len(arr)
stackl=[]
left=[]
stackr=[]
right=[]
width=[]
for i in range(0,n):
while stackl and stackl[-1][0]>=arr[i]:
stackl.pop()
if len(stackl)==0:
left.append(-1)
else:
left.append(stackl[-1][1])
stackl.append([arr[i],i])
for i in range(n-1,-1,-1):
while stackr and stackr[-1][0]>=arr[i]:
stackr.pop()
if len(stackr)==0:
right.append(n)
else:
right.append(stackr[-1][1])
stackr.append((arr[i],i))
right=right[::-1]
for i in range(0,n):
width.append(right[i]-left[i]-1)
maxx=-9999999999999999
for i in range(n):
val =arr[i]*width[i]
if val>maxx:
maxx=val
return maxx




