题目:Determine whether an integer is a palindrome. Do this without extra space.
不使用其它空间的意思是不是不调用其它函数??…
Palindrome integer就是说正看倒看都是一样的整数。比如23432,121等。
题目给的提示有:负数是否可以成为回文?给出的答案是不能。这也就意味着0可以。在考虑number reverse的时候,如果直接用integer或者string,要考虑溢出的问题,这个问题在之前的reverse integer中有遇到过,所以考虑使用long的数据类型。

考虑输入的int 数据是否在取值范围之内。

public class Solution {public boolean isPalindrome(int x) {if(x>Integer.MAX_VALUE ||x<Integer.MIN_VALUE){return false;}long num=0;long origin=(long)x;if(x>0 || x==0){while(x!=0){num=num*10+x%10;x=x/10;}if(origin==num){return true;}else{return false;}}else{return false;}
}}

Palindrome Numer相关推荐

  1. 【LeetCode】Palindrome Partitioning 解题报告

    [题目] Given a string s, partition s such that every substring of the partition is a palindrome. Retur ...

  2. 234. Palindrome Linked List - Easy

    Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false ...

  3. LeetCode 125 Valid Palindrome(有效回文)(*)

    版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/5062 ...

  4. Lintcode108 Palindrome Partitioning || solution 题解

    [题目描述] Given a strings, cutsinto some substrings such that every substring is a palindrome. Return t ...

  5. 数位DP 回文序列 POJ-3280 Cheapest Palindrome

    Cheapest Palindrome [ POJ - 3280 ] 题目大意: 给定字符串s,长度为m,由n个小写字母组成.在s的任意位置增删字母,把它变成回文串,增删特定字母的花费不同,求最小花费 ...

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

    看到这个题目的时候,首先不认识 Determine这个单词.英文不好没办法,查了下是确认的意思,然后不懂 palindrome这个单词, 查了下是回文的意思. 问题是 回文是个什么东西,官方解释: A ...

  7. [leetcode] Palindrome Number

    2019独角兽企业重金招聘Python工程师标准>>> Determine whether an integer is a palindrome. Do this without e ...

  8. Uva - 12050 Palindrome Numbers【数论】

    题目链接:uva 12050 - Palindrome Numbers 题意:求第n个回文串 思路:首先可以知道的是长度为k的回文串个数有9*10^(k-1),那么依次计算,得出n是长度为多少的串,然 ...

  9. 【leetcode】132. Palindrome Partitioning II

    题目如下: 解题思路:本题是[leetcode]131. Palindrome Partitioning的升级版,要求的是求出最小cuts,如果用[leetcode]131. Palindrome P ...

最新文章

  1. UI培训教程之系统图标如何设计?
  2. 100G内存下,MySQL查询200G大表会OOM么?
  3. 经典图书《重构:改善既有代码的设计》图灵再版出版倒计时
  4. 从Promise来看JavaScript中的Event Loop、Tasks和Microtasks
  5. mysql利用存储过程批量插入数据
  6. Android——RatingBar(评价条)相关知识总结贴
  7. Dominant Indices(CF 1009 F)
  8. [转载]AngularJS之Factory vs Service vs Provider
  9. pythonset是什么类型的游戏_Python集合(set)类型的操作
  10. Python中yield简单用法
  11. CCNA初认识——链路捆绑命令
  12. Luogu 3267 [JLOI2016/SHOI2016]侦察守卫
  13. Mycat概述、核心概念及linux安装、运行、登录
  14. 《积极上瘾》读后感范文5000字
  15. MATLAB提取 .fig 文件中的数据
  16. 求两个数最大公因数的c语言程序
  17. 计算机安装程序的文件名一般是什么,[电脑基础知识]什么是文件的后缀名.doc
  18. 【python】【Gif制作】使用多张图片合成gif动图
  19. 路由器配置(新手上路,比较全面,强烈推荐)
  20. 《感动中国》2005年度人物评选揭晓

热门文章

  1. 【JDM】弯道王子,最强马6,马自达Mazda 6 MPS
  2. java socket分包粘包 代码_分享java中处理socket通信过程中粘包情况的实例代码
  3. 《Python绝技:运用Python成为顶级黑客》python3实践记录
  4. Linux设备模型之device_add
  5. 学生选课系统业务需求
  6. WIN7 32/64位安装SQL Server 2005详细步骤(图文)
  7. Thread out-of-synch 错误
  8. This Python interpreter is in a conda environment问题解决
  9. no transaction is in progresss
  10. [高数][高昆轮][高等数学上][第一章-函数与极限]02.数列的极限