Can't figure about the error

my code worked for case 0, case 1, case 3
but I can’t figure out why it’s not working for test case 2…