wrong ans
Largest area under histogram
- define a stack and push the first element’s index into it
- if the current element is less than the element at top, pop until the stack is empty or the current element >= top
- while popping calculate maxarea = max(maxarea, (i-top)*arr[top])
- push this element
- at the end, until the stack is empty use the same formula for maxarea again
The code that you provided was empty