Solution by java


  • 0
    M
    public boolean isPalindrome(int x) {
            boolean result = false;
            String temp = "";
            StringBuilder re = new StringBuilder();
            if( x<= 9 && x >= 0 )
            {
                result = true;
            }
            if( x < 0 )
            {
                result = false;
            }
            else 
            {
                temp = Integer.toString(x);
                for (int i = temp.length() -1 ; i >= 0; i --)
                {
                    re.append(temp.charAt(i));
                    System.out.println(re);
                }
                String get = re.toString();
                System.out.println(get);
                System.out.println(temp);
                if(get.endsWith(temp))
                {
                	result = true;
                }
    
            }
            return result;
        }
    

Log in to reply
 

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