Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
max area rectangle
histogram = [6, 2, 5, 4, 5, 1, 6] stack = list() max_area = 0 index = 0 area=0 while index < len(histogram): if (not stack) or (histogram[stack[-1]] <= histogram[index]): stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (histogram[top_of_stack] * ((index - stack[-1] - 1) if stack else index)) max_area = max(max_area, area) print(stack,end=" ") print(index,end=" ") print(area) while stack: top_of_stack = stack.pop() area = (histogram[top_of_stack] * ((index - stack[-1] - 1) if stack else index)) max_area = max(max_area, area) print( max_area)
run
|
edit
|
history
|
help
0
shuru9
A list is shuffled and reshuffled till the 0th index of the list matches
PVJ-COMP1-1-EQUIPO1
quizcorrect
snake water gun game
Calender 2019
shuru6
Lab_I_2_25_11_2020
HW L3
Creating Person class