zoukankan      html  css  js  c++  java
  • Palindrome Number 2015年6月23日

    题目:

    判断一个数是不是回文数

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

    思路:借助上一道求整数逆序的思路,判断逆序后的数和原数是否相等就行。要注意,负数都不是回文数

    11506 / 11506 test cases passed.
    Status: Accepted
    Runtime: 588 ms
    Submitted: 0 minutes ago

    解答:

    public class Solution {
         public boolean isPalindrome(int x) {
            int pal = 0;
            int origin = x;
            if(x<0) {
                return false;
            }
             
            while(x!=0)
            {
                pal = pal*10+x % 10;
                x /= 10;
            }
    
             
          return pal == origin;
                
         }
        
    }
  • 相关阅读:
    K-means聚类
    支持向量机_原理
    回归+内插
    ftp 服务器
    cmd 切换python版本
    cookie
    类加载器
    GC
    jvm结构
    mysql文件
  • 原文地址:https://www.cnblogs.com/hixin/p/4595951.html
Copyright © 2011-2022 走看看