Test cases givng wrong answer

Majority of the test cases seem to be giving the wrong answer and I cant figure out how. Please point out the problem in my code