题目描述:

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

解题分析:

^_^个人觉得这道题没有什么可分析的,直接看代码就能明白^_^.

具体代码:

  1. public class Solution {
  2. public static boolean isPalindrome(int x) {
  3. if(x<0)
  4. return false;
  5. if(x>=0&x<=9)
  6. return true;
  7. int n=x;
  8. int sum=0;
  9. while(n!=0){
  10. int num1=n%10;
  11. int num2=n/10;
  12. sum=sum*10+num1;
  13. n=num2;
  14. }
  15. if(sum==x){
  16. return true;
  17. }
  18. return false;
  19. }
  20. }

【leetcode】9. Palindrome Number的更多相关文章

  1. 【LeetCode】9. Palindrome Number (2 solutions)

    Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. click t ...

  2. 【LeetCode】9. Palindrome Number 回文数

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:回文数,回文,题解,Leetcode, 力扣,Python ...

  3. 【leetcode】 9. palindrome number

    @requires_authorization @author johnsondu @create_time 2015.7.13 9:48 @url [palindrome-number](https ...

  4. 【LeetCode】009. Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  5. 【LeetCode】9 Palindrome Number 回文数判定

    题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could neg ...

  6. 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)

    [LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...

  7. 【LeetCode】137. Single Number II 解题报告(Python)

    [LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...

  8. 【LeetCode】306. Additive Number 解题报告(Python)

    [LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http: ...

  9. 【LeetCode】452. Minimum Number of Arrows to Burst Balloons 解题报告(Python)

    [LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https ...

随机推荐

  1. Spring aop实现方式记录

    原文地址:http://blog.csdn.net/moreevan/article/details/11977115 Spring提供了两种方式来生成代理对象: JDKProxy和Cglib,具体使 ...

  2. Java模拟登录系统抓取内容【转载】

    没有看考勤的习惯,导致我的一天班白上了,都是钱啊,系统也不发个邮件通知下....     为了避免以后还有类似状况特别写了个java模拟登录抓取考勤内容的方法(部分代码来自网络),希望有人修改后也可以 ...

  3. ios-NSString总结

    1.常用功能使用 1)初始化 NSString *astring = @"This is a String!";                             //固定字 ...

  4. android153 笔记 5

    52. Linux中跨进程通信的几种方式 . linux编程全部是基于文件管理的. # 管道( pipe ):管道也是一个文件,一个进程负责读一个进程负责写,管道是一种半双工(2边可以通信但是不能是同 ...

  5. XtraBackup原理5

    http://www.cnblogs.com/gomysql/p/3650645.html xtrabackup是Percona公司CTO Vadim参与开发的一款基于InnoDB的在线热备工具,具有 ...

  6. 使用Areas(区域)分离ASP.NET MVC 项目

    在使用Areas区域时,如果使用默认路由表,将造成路由表冲突,这种情况需要修改一下区域内<区域名称>AreaRegistration.cs和/App_Start/RouteConfig.a ...

  7. MySQL_前缀索引_建立

    -- 查看出现频率select count(*) as cnt,cityfrom sakila.city_demo group by city order by cnt desc limit 10; ...

  8. NODE编程(二)--异步编程技术

    在Node世界里流行两种响应逻辑管理方式,回调和事件监听. 回调通常用来定义一次性响应的逻辑.比如对于数据的查询,可以指定一个回调函数来确定如何处理查询结果. 事件监听器,本质上也是一个回调,不同的是 ...

  9. JPA与ORM以及Hibernate

  10. 关于XShell的常见使用和设置以及Linux中的常见命令.

    本文部分转自:http://sundful.iteye.com/blog/704079 和 http://www.vckai.com/p/5 有时候在XShell中操作的一些命令傻傻的分不清这个命令到 ...