it gives wrong answer for all test cases but works correctly for sample test case
Histogram largest area
@dhairya16
In the else case of while() loop, there may be chances when current ith element is smaller than more then 1 element in the stack (i.e. there are more element present in the stack that are greater than current a[i]), so you need to use while loop there also as used at end till the stack is empty.
Also initialize the max_arr with 0 otherwise it may take some garbage value for comparison
I am also attaching the corrected code in case you want to have a look at it.https://ide.codingblocks.com/s/243509
@dhairya16
Please also remember to mark this doubt as resolved if you don’t have any further query related to this.