Why one test case gets failed?

solution of 8545 should be 1444 but your code gives 8444, your if condition is partially wrong
Corrected code