Getting some errors

I have implemented the code for this question. But it seems that there are some errors. I am not able to rectify those…

And plz tell if the logic of my code is correct or not…

@sanjit_15,
Try now, Code

I guess, its still not working…
I need help regarding this question…

@sanjit_15,
No seg fault now, Code, you should try dry run on sample test case for finding bug.

How do I get correct output for this question?
Plz tell where is the logic error in my code!..

@sanjit_15,
You should try dry run on the sample test case.

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.