Can i improve it further?


  • 0
    A
    class Solution {
     public:
        bool isPalindrome(int x) {
            if(x<0)
        return false;
        int z=0;
        int y=x;
        while(x!=0)
        {
            z=z*10+(x%10);
            x=x/10;
        }
        if(y==z)
        {
            return true;
        }
        return false;
    }
    };

Log in to reply
 

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