How this code is working for 3 test case but 4th case is working fine for my dry run concept

please debug this code…one test case is not passing… but smooth runnung on my dry run