100%,c++ solution


  • 0
        bool isPalindrome(int x) {
        	if(x<0)
        		return false;
        	if(x<10)
        		return true;
        	int left=1;
        	while(x/left>=10)
        		left*=10;
        	int right=1;
        	while(left>right){
        		if(x/left%10==(x/right)%10){
        			left/=10;
        			right*=10;
        		}
        		else
        			return false;
        	}
        	return true;
        }
    

Log in to reply
 

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