Maximum Histogram area

This code fails if the array is strictly increasing or decreasing how can i correct it?Plz suggest

hello @aryamaan1011
u r not handling case 3 of the algorithm
image

for ur refernce -> https://ide.codingblocks.com/s/285341

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.