首页 > 代码库 > Palindrome Number

Palindrome Number

Palindrome Number 

Determine whether an integer is a palindrome. Do this without extra space.

 1 public class Solution { 2     public boolean isPalindrome(int x) { 3         boolean isPal = true; 4         String str = String.valueOf(x); 5         for(int i = 0, j = str.length() - 1; i <= j; i++, j--){ 6             if(str.charAt(i) != str.charAt(j)){ 7                 isPal = false; 8                 break; 9             }10         }11         return isPal;12     }13 }

 

Palindrome Number