my ans is correct for custom input but all testcase are wrong.
Max area of histrogram
your approach seems a bit complicated, use this instead
- 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
@ seemantanishth
I have finded nearest smaller to left and then similarly to right then - them for width and then max area.