palindrome-number

来源:互联网 发布:spine 3.6 mac 破解版 编辑:程序博客网 时间:2024/05/21 17:40

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

思路:将数字reverse,查看是否相同考虑空间复杂性,

public class Solution {    public boolean isPalindrome(int x) {        int oldvalue=x;        int temp=0;        while(x>0){            temp=temp*10+x%10;            x/=10;        }        return oldvalue==temp;            }}

原创粉丝点击