5 line of java


  • 0
    H

    public boolean isPalindrome(int x) {
    String s = Integer.toString(x);

        for(int i = 0; i <= (s.length() / 2); i++){
            if(s.charAt(i) != s.charAt(s.length() - i - 1)) return false;
        }
        
        return true;
    }

  • 0
    I

    can't use extra space!


Log in to reply
 

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