class Solution {
public:
bool isPalindrome(int x)
{
if(x<0)
return false;
else if(x==0)
return true;
else
{
string temp=to_string(x);
int left=0,right=temp.size()-1;
int tag=1;
while(left<=right)
{
if(temp[left]==temp[right])
{
left++;
right--;
}
}
else
{
tag=0;
}
if(tag)
return true;
else
{
return false;
}
}
return true;
}
};
每日一题 6.10
最新推荐文章于 2021-06-10 21:18:54 发布