Wrong results - Manually testing all test cases give correct answers

I have checked the test cases and all my answers match.
Please let me know as to why are the answers wrong.

hello @sparab
please share ur code using cb ide.
also with which test cases u have verified ur code?
is it cb test cases or ur own

Here is the code

Yes I have used the CB Test cases itself - 1 & 3 fail, 2 works

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.