9. Palindrome Number 2016-04-13 9. Palindrome Number key points negative numbers overflow no extra space The break point is sum >= x –> (sum ==x)||(sum/10==x) source code1234567891011public boolean isPalindrome(int x) { if(x < 0 || (x!=0 && x%10==0)){ return false; } int sum = 0; while(x > sum){ sum = x%10 + sum*10; x/=10; } return (sum ==x)||(sum/10==x);} 最后更新时间:2017年6月17日 12:17 转载请注明来自于:http://duyao.github.io/2016/04/13/9-Palindrome-Number/ Prev 221. Maximal Square Next 89. Gray Code