No one said converting to string is not an option (easy to understand)


  • 0
    R
    class Solution {
    public:
        bool isPalindrome(int x) {
            string s = to_string(x);
            int i = 0;
            int j = s.size() - 1;
            while (i < j) {
                if (s[i] != s[j])
                    return false;
                i++;
                j--;
            }
            return true;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.