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
denemeler
Doki Doki Study Club p.one
Python3 - PDF PAGES SEPARATION
Mixing string with number
hw11
hello
Convert list into set
Z Pattern ( first python program)
BMO1 Q1 1994
binary