My easy solution with Java in 7 lines


  • 0
    F

    This is my code. If you have a better code pls tell me. Thanks~

    public boolean isPalindrome(int x) {
        int result = 0;
        for(int temp = x; temp > 0 ; temp /= 10){
    	result = 10 * result + temp % 10;
        }
        return x == result ? true : false;
    }
    

Log in to reply
 

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