【leetcode】9. Palindrome Number

时间:2022-06-20 03:00:43

题目描述:

Determine whether an integer is a palindrome. Do this without extra space.

解题分析:

^_^个人觉得这道题没有什么可分析的,直接看代码就能明白^_^.

具体代码:

 public class Solution {
public static boolean isPalindrome(int x) {
if(x<0)
return false;
if(x>=0&x<=9)
return true;
int n=x;
int sum=0;
while(n!=0){
int num1=n%10;
int num2=n/10;
sum=sum*10+num1;
n=num2;
}
if(sum==x){
return true;
}
return false;
}
}