码迷,mamicode.com
首页 > 其他好文 > 详细

Palindrome Number

时间:2014-11-09 23:37:34      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   sp   for   div   on   

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

标签:style   blog   io   color   ar   sp   for   div   on   

原文地址:http://www.cnblogs.com/luckygxf/p/4086111.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!