查看算法描述

算法实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Solution {
public boolean isPalindrome(int x) {
int temp = x;
int temp2 = x;
int i = 0;
int flag = x<0?1:0;
for(;temp>0;)
{
temp /= 10;
i++;
}
int one;
for(;x>0;)
{
int remainer = x%10;
one = (int)(temp2 / Math.pow(10,--i)%10);
if(one != remainer)
{
flag++;
}
x /= 10;

}
return flag==0;
}
}