Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321

Solution 1:

class Solution {
public:
int reverse(int x)
{
int result = ;
while(x != )
{
if( x > && result > (INT_MAX - x % ) / ||
x < && result < (INT_MIN - x % ) / )
return ;
result = result * + x % ;
x = x / ;
}
return result;
}
};

Reverse Integer ---- LeetCode 007的更多相关文章

  1. Reverse Integer LeetCode Java

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 public cl ...

  2. Reverse Integer [LeetCode]

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to ...

  3. LeetCode 【2】 Reverse Integer --007

    六月箴言 万物之中,希望最美:最美之物,永不凋零.—— 斯蒂芬·金 第二周算法记录 007 -- Reverse Integer (整数反转) 题干英文版: Given a 32-bit signed ...

  4. LeetCode 7 Reverse Integer(反转数字)

    题目来源:https://leetcode.com/problems/reverse-integer/ Reverse digits of an integer. Example1: x = 123, ...

  5. 《LeetBook》leetcode题解(7): Reverse Integer[E]——处理溢出的技巧

    我现在在做一个叫<leetbook>的开源书项目,把解题思路都同步更新到github上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetboo ...

  6. No.007 Reverse Integer

    7. Reverse Integer Total Accepted: 153147 Total Submissions: 644103 Difficulty: Easy Reverse digits ...

  7. leetcode第七题Reverse Integer (java)

    Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, retu ...

  8. LeetCode之Easy篇 ——(7)Reverse Integer

    7.Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: Out ...

  9. LeetCode之“数学”:Reverse Integer && Reverse Bits

    1. Reverse Integer 题目链接 题目要求: Reverse digits of an integer. Example1: x = 123, return 321 Example2:  ...

随机推荐

  1. ajax轮询session阻塞问题

    近来读了几篇关于ASP.NET下Session机制的文章,结合自己的实际应用,有点感想:        在ASP.NET的Session的默认机制下,对同一个SessionID下的用户请求ASP.NE ...

  2. hdu----(5023)A Corrupt Mayor's Performance Art(线段树区间更新以及区间查询)

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  3. 10大html5前端框架

    Bootstrap 首先说 Bootstrap,估计你也猜到会先说或者一定会有这个( 呵呵了 ),这是说明它的强大之处,拥有框架一壁江山的势气.自己刚入道的时候本着代码任何一个字母都得自己敲出来挡我者 ...

  4. for循环的嵌套——7月24日

      练习一:输入一个正整数,用for循环嵌套求阶乘的和 //输入一个正整数,求1!+2!+....+n! 用for循环嵌套 Console.Write("请输入一个正整数:"); ...

  5. IE10 CSS hack,IE兼容问题

    IE10 CSS hack,IE兼容问题 作者: 雪影 发表于2013 年 4 月 25 日 分类:技术分享 | 暂无评论 | 人气: 376 度 首先,ie10不支持条件注释了. 方法一:特性检测: ...

  6. 如何采集所有QQ群成员?

    首先,你需要有一个CHROME浏览器其实,你要装一个叫REGEX SCRAPER的插件 在qun.qzone.qq.com打开你的QQ群页面-查看群成员 点击REGEX 插件, 粘贴上这个代码 tex ...

  7. 学习记录013-NFS相关知识点

    一.NFS相关知识点 1.NFS常用的路径/etc/exports NFS服务主配置文件,配置NFS具体共享服务的地点/usr/sbin/exportfs NFS服务的管理命令,exportfs -a ...

  8. ASP.NET MVC 在子页中引用头文件

    在很多时候我们把网站公共的js.css文件放在模板页中,这样在具体的每一个页面里面就不需要单独引用. ASP.NET WebForm里面使用.site文件. 而在ASP.NET MVC 中使用了类似下 ...

  9. changepassword.c 0.9:一个通过WEB界面更改LINUX用户密码的程序

    偶然看到一个用C语言写的CGI程序,可以以WEB界面(无需单独再写HTML)的方式修改用户自己的密码.该程序具有同时修改samba及squid密码的能力. 步骤: 1.下载并解压,并读一下README ...

  10. Code First Migrations更新数据库结构的具体步骤

    一.打开程序包管理器控制台 当你的实体模型与数据库架构不一致时,引发以下错误:The model backingthe 'SchoolContext' context has changed sinc ...