leetcode-9

 Palindrome Number

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

public class Solution {
    public boolean isPalindrome(int x) {
        if(x<0||(x!=0&&x%10==0)) return false;
        int rev=0;
        while(x>rev){
            rev=rev*10+x%10;
            x=x/10;
        }
        return (x==rev||x==rev/10);
    }
}

  

posted @ 2017-03-15 22:41  世人谓我恋长安  阅读(97)  评论(0编辑  收藏  举报