7-line simple accepted Java code,no extra space

  • 0
    # code block
        public boolean isPalindrome(int x) {
            return x >= 0 && x == result(x, 0);
        static int result(int x,int sum){
            if(x==0)return sum;
            return result(x/10,x%10+10*sum);

Log in to reply

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