My Java Solution


  • 0
     public boolean isPalindrome(int x) {
           if(x < 0)	return false;
    		int factor  = 1;
    		while(x / factor >= 10){
    			factor *= 10;
    		}
    		while(x != 0){
    			if((x / factor) != (x % 10)){
    				return false;
    			}
    			x = (x % factor) / 10;
    			factor /= 100;
    		}
    		return true;
        }

Log in to reply
 

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