https://leetcode.com/problems/palindrome-number/

Solution

The easiest way is to convert n to string s, and compare s to the reverse(s)

    bool isPalindrome(int x) {
        string s = to_string(s);
        string t = s;
        reverse(t.begin(), t.end());
        return s == t;
    }

The other way, which doesn't require to convert to string is to calculate the reversed number of n

    bool isPalindrome(int x) {
        long y = 0;
        int z = x;
        while (x > 0) {
            y = y*10 + x%10;
            x = x / 10;
        }
        return z == y;
    }

Runtime: O(log_10(n))