[leetcode] PalindromeNumber

/**
* Determine whether an integer is a palindrome. Do this without extra space.
* */
public class PalindromeNumber {
    public class Solution {
        public boolean isPalindrome(int x) {
            int temResult = 0;
            int temX = x;
            while (temX > 0) {
                temResult = temResult * 10 + temX % 10;
                temX = temX / 10;
            }
            return x == temResult;
        }
    }
}

你可能感兴趣的:(LeetCode)