Preview:
class Solution {
public:
    bool isPalindrome(int x) {
        string s1=to_string(x);
      string s=to_string(x);
        int n=s.length();
        for(int i=0;i<n/2;i++)
        {
            swap(s[i],s[n-1-i]);
        }
        if(s1==s) return true;
        else return false;
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter