0

Why is this wrong? Test case 3 is wrong yet since it is hidden I do not know where my code is wrong. Rest of test cases is OK.

47 Code Project - Palindrome numbers https://code.sololearn.com/cjkU3eJ5IOmi/?ref=app

2nd Jul 2021, 7:32 PM
Jakub
Jakub - avatar
4 Respuestas
+ 1
Jakub Your code is too much complicated. Here is simple one: bool isPalindrome(int x) { //complete the function int n = 0, s = 0, r; n = x; while (n != 0) { r = n % 10; s = s * 10 + r; n = n / 10; } if (x == s) return true; return false; }
3rd Jul 2021, 12:52 AM
A͢J
A͢J - avatar
+ 1
Thank you very much for this clarification.
3rd Jul 2021, 10:56 AM
Jakub
Jakub - avatar
0
Not sure why you used long . Try your code with numbers like : 001100 010 000011110000 Your code doesn't count the zeros in front at all. Here's a rather simple version. https://code.sololearn.com/ca1285a53A3A I'll let you know if I find the mistake.
2nd Jul 2021, 8:10 PM
Saphal Poudyal
Saphal Poudyal - avatar
- 1
Thank you very much for your help. I have not tested my code for numbers starting with 0.
2nd Jul 2021, 8:33 PM
Jakub
Jakub - avatar