标签:
Palindrome Number
问题:
Determine whether an integer is a palindrome. Do this without extra space.
思路:
常用的进制遍历方法
while(num != 0) { remian = num % 进制; num /= 进制; }
我的代码:
public class Solution { public boolean isPalindrome(int x) { if(x < 0) return false; int reverse = reverse(x); return reverse == x; } public int reverse(int x) { int rst = 0; while(x != 0) { rst = rst * 10 + x % 10; x /= 10; } return rst; } }
学习之处:
标签:
原文地址:http://www.cnblogs.com/sunshisonghit/p/4329279.html