Eight line code double pointer no reverse

  • -1
      public boolean isPalindrome(int x) {
                String s=null;
                if(x<0)   return false;
                else   s=String.valueOf(x);
                int i=0;int j=s.length()-1;
                    if(s.charAt(i)==s.charAt(j)){ j--;i++;}
                    else return false;
                return true;

Log in to reply

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