leetcode [#9] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目Determine whether an integer is a palindrome. Do this without extra space.
Some hints:Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string, note the restriction of using extra space.
解决方案12345678910111213public class Solution { public boolean isPalindrome(int x) { if(x < 0 || (x != 0 && x % 10 == 0)) return false; if(x == 0) return true; int tmp = 0; int x0 = x; while(x > 0){ ...阅读全文
题目Determine whether an integer is a palindrome. Do this without extra space.
Some hints:Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string, note the restriction of using extra space.
解决方案12345678910111213public class Solution { public boolean isPalindrome(int x) { if(x < 0 || (x != 0 && x % 10 == 0)) return false; if(x == 0) return true; int tmp = 0; int x0 = x; while(x > 0){ ...阅读全文