Rain water trapping

my code is giving run time error
can you check and point out where I went wrong?

P.S. Would really appreciate if you will check my code and tell where is the mistake rather than providing me with your code.

Thanks

Hello @mahima i have corrected your code :

I guess you shared the wrong link here.

Can you please check and share the correct code link. The link which you shared has code for some other problem.

@mahima I am very sorry for that mistake:
this is your corrected code: https://ide.codingblocks.com/s/428090

No worries. Thanks for correcting it out.

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.

The code is still not working. Getting Error - /bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

@mahima it is passing all the test cases on my side:
you can try to submit here:https://hack.codingblocks.com/app/practice/2/327/problem

Everything was fine except - array declaration of large sizes (10^6). I did so because of the constraint mentioned in the problem. But now I made it of size n and it worked.

@mahima is it passing test cases now from your side?

yes it is passing all the test cases successfuly.

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.