这题好简单

public class Solution {
    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        
        List<Integer> number = new ArrayList<Integer>();
        
        while (x >= 10) {
            number.add(x%10);
            x = x / 10;
        }
        number.add(x);
        int p = 0;
        int q = number.size() - 1;
        while (p < q) {
            if (number.get(p) != number.get(q)) {
                return false;
            }
            p++;
            q--;
        }
        return true;
    }
}

chenatu
106 声望12 粉丝