The code is failing for two test cases

plz have a look and help me with this code