9. 回文数
class Solution {
public boolean isPalindrome(int x
) {
String s
= String
.valueOf(x
);
StringBuffer sb
=new StringBuffer(s
);
if(s
.equals(sb
.reverse().toString())){
return true;
}else{
return false;
}
}
}
class Solution {
public boolean isPalindrome(int x
) {
int n
= 0;
int m
=x
;
if(x
<0){
return false;
}
while(x
!=0){
n
= n
*10 + x
%10;
x
= x
/10;
}
return m
== n
;
}
}
转载请注明原文地址: https://lol.8miu.com/read-30527.html