public class Solution {
public boolean isPalindrome(int x) {
String s=String.valueOf(x);
char c[]= s.toCharArray();
if(x<0) return false;
if(c.length==1) return true;
int i,j;
for(i=0,j=s.length()-1;i<=j;)
{
if(c[i]==c[j])
{
i++;
j--;
}else
return false;
}
if(i>j) return true;
else return false;
}
}
LeetCode 9. Palindrome Number
最新推荐文章于 2022-04-02 15:31:39 发布