The easiest way to solve this problem


  • 4
    Y
    class Solution {
    public:
        bool isPalindrome(int x) {
            if(x<0)
    			return false;
    		int dupx=x;
    		int revsx=0;
    		while(dupx!=0)
    		{
    			revsx=revsx*10+dupx%10;
    			dupx=dupx/10;
    		}
    		if(revsx==x)
    			return true;
    		else
    			return false;
        }
    };

Log in to reply
 

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