看到这个题目的时候,首先不认识 Determine这个单词。英文不好没办法,查了下是确认的意思,然后不懂 palindrome这个单词, 查了下是回文的意思。

问题是 回文是个什么东西,官方解释: A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. 回文

尽管英文不好,可是这个英文解释还是看懂了的。意思就是从前读到后面和倒过来读是一样的。

然后又不理解后面那句 do this without extra space. 大概意思是实现的时候不能使用其它空间,事实上还是不懂。

不知道第二个方法里的,Math.pow()这种方法的调用算不算使用其它空间。

public class palindrome {//using with extra spacepublic static boolean check(int x){String temp = Integer.toString(x);boolean flag = true;for(int i=0;i<temp.length()/2;i++){char a = temp.charAt(i);char b = temp.charAt(temp.length()-i-1);if(a!=b){flag = false;}}return flag;}//using without extra spacepublic static boolean check2(int x){if(x<0)return false;int n=1;int temp = x;while(temp/10!=0){temp=temp/10;n++;}for(int i=0;i<n/2;i++){int a = i;int b = n-1-i;if(getInt(x,a)!=getInt(x,b)){return false;}}return true;}// 比方 896698 这个数字。要获取百位,用896698除以100。得到8966然后取余10得到6。即为百位的数值private static int getInt(int x,int i){int a =  (int) Math.pow(10, i);return (x/a)%10;}
}

本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5154517.html,如需转载请自行联系原作者

Determine whether an integer is a palindrome. Do this without extra space.相关推荐

  1. [leetcode] Palindrome Number

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

  2. Leetcode: Palindrome Numbers

    Determine whether an integer is a palindrome. Do this without extra space. 尝试用两头分别比较的方法,结果发现无法解决1000 ...

  3. 9. Palindrome Number

    题目: Determine whether an integer is a palindrome. Do this without extra space. click to show spoiler ...

  4. 【LeetCode从零单排】No.9 Palindrome Number

    题目       这道题是迄今为止最快通过的一道题,改了两次就过了,runtime一般(中等偏下,这点不太满意).Palindrome就是判断一个整数是否对称. Determine whether a ...

  5. 【Leetcode】Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. 思路:若使用[Leetcode]Reverse I ...

  6. [LeetCode] Palindrome Number Valid Palindrome - 回文系列问题

    题目概述: Determine whether an integer is a palindrome. Do this without extra space. 题目分析: 判断数字是否是回文 例如1 ...

  7. [LeetCode] 9. Palindrome Number

    传送门 Description Determine whether an integer is a palindrome. Do this without extra space. 思路 题意:判断输 ...

  8. LeetCode之Palindrome Number(回文数)

    1.题目 Determine whether an integer is a palindrome. Do this without extra space. 2.代码实现 代码实现1 public ...

  9. LeetCode 9. Palindrome Number

    题目: Determine whether an integer is a palindrome. Do this without extra space. 思路: 设置一个与x相等的num,因为要留 ...

最新文章

  1. 推荐!Sublime Text 最佳插件列表
  2. Git、TortoiseGit、GitHub、Gitee、GitLab 安装与入门使用
  3. Html代码seo优化最佳布局实例讲解
  4. Linux 查看文件指定行数 内容
  5. 基于Tensorflow实现多层感知机网络MLPs
  6. 《JAVA与模式》之观察者模式
  7. servlet中filter的的异步问题以及JSP与servlet配合时filter的注意
  8. C++ MathGL 二维数据绘图
  9. icmp基于tcp还是udp_imi -- 基于PHP协程应用开发框架,支持WebSocket,TCP,UDP应用开发...
  10. hadoop大数据架构
  11. BOSS直聘免费下载个人简历为PDF的方法
  12. flask框架之jinjia2模版语法详解
  13. Coinbase与华尔街的内幕故事
  14. 资源暂时不可用错误(Out of memery)完美解决方案
  15. 微信小程序怎么用? 老徐小程序!
  16. codeforces-1202C-WASD-string
  17. DIY人体红外报警器手机接收通知 防贼防盗防老王 物联网 智能家居
  18. jQuery WeUI v0.1.0 发布了 - 微信公众账号开发者的福音
  19. 互联网盈利模式研习笔记 1:流量变现
  20. java实现Word文档(doc、docx)在线查看功能(前台+后台)

热门文章

  1. windows10下使用virtualenv虚拟技术,管理多个python版本,多个项目包环境
  2. 车辆检测--DAVE: A Unified Framework for Fast Vehicle Detection and Annotation
  3. Java 使用线程池ThreadPool:newFixedThreadPool
  4. 笔记本电脑无线被禁用 是哪个服务器,无线网关,小编教你笔记本无线网络禁用后怎么开启...
  5. php自定义控件,小程序自定义组件的实现方法(代码)
  6. mysql配置日志老化配置_mysql中日志的配置与分析
  7. cad打印样式ctb丢失_CAD制图软件中如何设置CAD打印样式表(CTB)?
  8. pandas describe函数_PANDAS: 新手教程 一
  9. 真厉害用python只要50行代码爬取黑丝美眉纯欲高清图
  10. 5秒到1秒,记一次效果“非常”显著的性能优化