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
4 ответов
+ 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;
}
+ 1
Thank you very much for this clarification.
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.
- 1
Thank you very much for your help. I have not tested my code for numbers starting with 0.