Test cases givng wrong answer

Test cases givng wrong answer. Please point out what is the error in my code as the compiler seems to give the correct answer