class Solution {
public:
bool isPalindrome(int x) {
// Note: The Solution object is instantiated only once and is reused by each test case.
if(x<0)
return false;
if(x==0)
return true;
int oldVal=x;
int newVal=0;
while(x>0)
{
newVal=newVal*10+x%10;
x/=10;
}
return oldVal==newVal;
}
};
【leetcode】Palindrome Number
最新推荐文章于 2021-10-15 15:40:03 发布