package easy;
import java.util.Arrays;
import java.util.List;
public class LC_9_huiwen {
public static boolean isPalindrome(int x) {
if (x<0 || (x%10==0 && x!=0)) return false;
int recv=0;
int pop=0;
while (recv<x)
{
pop=x%10;
x=x/10;
recv=recv*10+pop;
}
return recv==x || recv/10==x;
}
public static void main(String[] args) {
List<Integer> inputs=Arrays.asList(12321,-123,153423646,10,9,1234543210,0);
for (int input :inputs)
System.out.println(LC_9_huiwen.isPalindrome(input));
}
}
这道题我的做法和官方做法一摸一样,有种那种做出来就是标准答案的快感
mark一下