Histogram area using stack

please check my area array is storing only 0

hello @bhattanurag426

after the loop ends, the stack might still not be empty .
so that will also effect answer

but still why my array for area is 0 at every index

…

yeah it will reamin 0,
becuase in input u have given
5
1 2 3 4 5

with this input , ur else statement will never execute and hence the array will never update

refer this ->

u need to add that extra non empty stack case, it will work fine

https://ide.codingblocks.com/s/462208 referred your code now my code is running correct for the given test case but failing for other test cases

use long long.

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.