9. Palindrome Number

class Solution {
    public boolean isPalindrome(int x) {
        int ans = 0, xx = x;
        while (x > 0){
            int cur = x % 10;
            ans = ans * 10 + cur;
            x /= 10;
        }

        return ans == xx;
    }
}

results for ""

    No results matching ""