leetcode reverse integer&&Palindrome Number
public class Solution {
public int reverse(int x) {
int ret=0;
while(x!=0)
{
int t=x%10;
ret=ret*10+t;
x=x/10;
}
return ret;
}
}
public class Solution {
public boolean isPalindrome(int x) {
if(x<0) return false;
if(x==0) return true;
int ret=0;
int xold=x;
while(x!=0)
{
int temp= x%10; // zui hou yi wei
ret=ret*10+temp;
x=x/10;
}
if(ret==xold) return true;
return false;
}
}
leetcode reverse integer&&Palindrome Number的更多相关文章
- Reverse Integer - Palindrome Number - 简单模拟
第一个题目是将整数进行反转,这个题实现反转并不难,主要关键点在于如何进行溢出判断.溢出判断再上一篇字符串转整数中已有介绍,本题采用其中的第三种方法,将数字转为字符串,使用字符串比较大小的方法进行比较. ...
- leetcode bug & 9. Palindrome Number
leetcode bug & 9. Palindrome Number bug shit bug "use strict"; /** * * @author xgqfrms ...
- [LeetCode 题解]:Palindrome Number
前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 1.题目描述 Determine ...
- LeetCode(9) - Palindrome Number
题目要求判断一个整数是不是回文数,假设输入是1234321,就返回true,输入的是123421,就返回false.题目要求in-place,思路其实很简单,在LeetCode(7)里面我们刚好做了r ...
- 【一天一道LeetCode】#9. Palindrome Number
一天一道LeetCode系列 (一)题目 Determine whether an integer is a palindrome. Do this without extra space. Some ...
- leetcode题解 9. Palindrome Number
9. Palindrome Number 题目: Determine whether an integer is a palindrome. Do this without extra space. ...
- 【LeetCode】9. Palindrome Number (2 solutions)
Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. click t ...
- 《LeetBook》leetcode题解(9):Palindrome Number[E]——回文数字
我现在在做一个叫<leetbook>的开源书项目,把解题思路都同步更新到github上了,需要的同学可以去看看 地址:https://github.com/hk029/leetcode 这 ...
- LeetCode Problem 9:Palindrome Number回文数
描述:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could nega ...
随机推荐
- Codevs 1074 食物链 2001年NOI全国竞赛
1074 食物链 2001年NOI全国竞赛 时间限制: 3 s 空间限制: 64000 KB 题目等级 : 钻石 Diamond 传送门 题目描述 Description 动物王国中有三类动物 A,B ...
- 高性能、高并发TCP服务器(多线程调用libevent)
from:http://blog.csdn.net/i_am_jojo/article/details/7587838 本文讲述的TCP服务器是模仿memcache中的TCP网络处理框架,其中是基于l ...
- linux-信号。
信号 信号是在软件层次上对中断机制的一种模拟,在原理上,一个进程收到一个信号与处理器收到一个中断请求可以说是一样的. 信号是异步的,一个进程不必通过任何操作来等待信号的到达,事实上,进程也不知道信号到 ...
- DOM 文档对象模型
document 对象(作为对象),是 DOM 的核心作用:对内容,属性,样式等操作属性:title:设置/返回当前文档的标题url:返回当前文档的 urlinnerHTML:获取指定对象内的内容bg ...
- JS分段上传文件(File)并使用MD5.js加密文件段用来后台校验
HTML <form method="POST" name="form1" action="/mupload/upload/" enc ...
- ubuntu下的软件安装
1.软件安装 最近开始将个人电脑由windows换成linux,第一步就是会装一些个人软件,以前玩linux都是用yum或者apt-get来进行安装. 下面介绍一下如何从官网下载文件并且安装的方法. ...
- 安装mysql-python需要碰到错误:Unable to find vcvarsall.bat 的解决方法
1.发现从https://pypi.python.org/pypi/MySQL-python/1.2.5#downloads 下载下来的python版本是2.7
- 2014年度辛星html教程夏季版第四节
我们前面也涉及了HTML中的一些东西,接下来我们要涉及到图像了,如果没有图像,即使文字的样式再多,再复杂,终归还是单调的,我们就需要用图片来给我们的网页增加更多的表现形式. ************* ...
- css小心德
内部块最好用百分比,微调时方便
- Java2_Java泛型
一. 泛型概念的提出(为什么需要泛型)? 首先,我们看下下面这段简短的代码: 1 public class GenericTest { 2 3 public static void main(Stri ...