Problem : PALL01 Problem - CodeChef
Although this code can be done successfully by reversing the integer digits but I tried submitting it using another approach. Can anyone tell me what is wrong with this code?
The problem is when the input is greater than 1000.
In your code you are comparing the first half with the second half in the same direction (left to right).
i.e. if the input is something like 1010, the code throws win as 10 == 10 and 1221 becomes loss as 12 != 21.
You have to compare the two halves in the opposite directions.