标签:als ase http leetcode ems *** down javadoc product
@requires_authorization
@author johnsondu
@create_time 2015.7.13 9:48
@url [palindrome-number](https://leetcode.com/problems/palindrome-number/)
/************************
* 分离出最左边和最右边的数
* 然后依次对照就可以
***********************/
class Solution {
public:
bool isPalindrome(int x) {
if(x < 0) return false;
if(x < 10) return true;
int base = 1;
while(x / base >=10) base *= 10;
while(x)
{
int ld = x / base;
int rd = x % 10;
if(ld != rd) return false;
x -= ld * base;
x /= 10;
base /= 100;
}
return true;
}
};
【leetcode】 9. palindrome number
标签:als ase http leetcode ems *** down javadoc product
原文地址:https://www.cnblogs.com/zhchoutai/p/8872553.html