Program is working fine for the given test case,yet all test cases are failing