Didn't I use extra space ?? how Accepted ?


  • 0
    O
    public boolean isPalindrome(int x) {
           if(x<0)return false;
           String y=x+"";
                while(y.length()!=1&&y.length()!=0) {
               if(y.charAt(0)!=y.charAt(y.length()-1))return false;
               else {
                   if(y.length()==1)return true;
                   y=y.substring(1,y.length()-1);
               }
           }
           return true;
        }

Log in to reply
 

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