leetcode-palindrome number

来源:互联网 发布:移动直播app 开源 源码 编辑:程序博客网 时间:2024/06/06 05:06
public boolean isPalindrome(int x) {        if(x<0)return false;        int y=0;        int z=x;        while(z>0){            int cur=z%10;            y=y*10+cur;            z=z/10;        }        return x==y;    }
想法很简单,因为正着和反着的value应该是一样的,那么就反着作为高位,先读就好了。
0 0