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 }

 

posted on 2014-11-09 22:57  luckygxf  阅读(145)  评论(0编辑  收藏  举报

导航