Please check this code and tell if this is the right approach and can i improve this code in any more way?

please see once. i will feel confident if u see. as i have invested alot of time in this.

@sirraghavgupta I went through your code, I must say, you made the right investment with the time. I did dry run of your code and it is giving correct output. Try submitting this on the site, I am sure it will get accepted. And you should feel confident about yourself, no matter what.

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.