why this code gives correct results on 1st test, and for all the remaining tests, all wrong, whats wrong in this code?