**解题思路:**
反转回文串,并判断与原始是否一致
//反转x判断是否与x一致
class Solution {
public boolean isPalindrome(int x) {
if(x < 0) return false;
int cur = 0;
//复制x
int num = x;
while(num != 0){
cur = 10 * cur + num % 10;
num /= 10;
}
return cur == x;
}
}
9. 回文数(Java)Leecode
于 2022-03-01 19:54:07 首次发布