my code is giving segmentation fault and
i am unable to find the error in the code
Histogram area problem
Hey @Nishant_08, since you have used array of int variable you will fail most of the test cases because value of a[i] will be in range of 0,10^9 . I would suggest you to use long long int array instead of int array.
Secondly, if you are taking array of size n which will have long long int value, add 0 at a[n+1] because we also have to look for value at a[n] , which is missing in your code, that’s why you are getting segmentation fault cause your last element might not be getting operated.
Thirdly when you are starting your for loop in your function, you should check in the beginning that if your stack is empty you will push a[i] instead of checking your if statement of current height and height[s.top()]
I would suggest you to make this changes, apply your new algorithm by coding and if you are still not able to get it, you can ask for my code. I will be happy to help you. Don’t give up
, keep coding 
sir i have made the changes, the code is running now but giving the wrong ans
Hey @Nishant_08 i am impressed that you have applied the changes as per my suggestion , Why you still getting wrong answer is because you are calculating area in wrong loop and also using those conditions that are appropriate. I would suggest you to watch prateek’s bhaiya video more cautiously and code it again. I know this time you will do it cause you know where your are repeating your mistake. Moreover ,if you still can’t then i will provide you with my solution with comments written on it .
Keep it up
i am impressed by your determination. Happy to help 
sir can you please provide me your code, i have tried many times but i am not able to find the error.
Sure Nishant i will provide you with my personal code till evening . Just be a little patient 
Hey @Nishant_08 i have wrote this code for you , and have also added comments for better understanding. Dry run this code on various test cases and identify your mistake 
Here’s your code : https://ide.codingblocks.com/s/333062
Keep coding @Nishant_08 wiith same determination 
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.