Reverse Integer ---- LeetCode 007
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的更多相关文章
- Reverse Integer LeetCode Java
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 public cl ...
- Reverse Integer [LeetCode]
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to ...
- LeetCode 【2】 Reverse Integer --007
六月箴言 万物之中,希望最美:最美之物,永不凋零.—— 斯蒂芬·金 第二周算法记录 007 -- Reverse Integer (整数反转) 题干英文版: Given a 32-bit signed ...
- LeetCode 7 Reverse Integer(反转数字)
题目来源:https://leetcode.com/problems/reverse-integer/ Reverse digits of an integer. Example1: x = 123, ...
- 《LeetBook》leetcode题解(7): Reverse Integer[E]——处理溢出的技巧
我现在在做一个叫<leetbook>的开源书项目,把解题思路都同步更新到github上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetboo ...
- No.007 Reverse Integer
7. Reverse Integer Total Accepted: 153147 Total Submissions: 644103 Difficulty: Easy Reverse digits ...
- leetcode第七题Reverse Integer (java)
Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, retu ...
- LeetCode之Easy篇 ——(7)Reverse Integer
7.Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: Out ...
- LeetCode之“数学”:Reverse Integer && Reverse Bits
1. Reverse Integer 题目链接 题目要求: Reverse digits of an integer. Example1: x = 123, return 321 Example2: ...
随机推荐
- HTML5自学笔记[ 3 ]表单验证反馈
表单控件对象的validity对象可以设置或返回相关的验证信息(在invalid事件处理中获取validity对象): 属性valid:为true所有验证通过,为False至少有一种验证失败. 属性v ...
- struts2在pom.xml中的配置
<dependencies> <dependency> <groupId>org.apache.struts</groupId> <artifac ...
- MyBatis核心配置文件模版
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLI ...
- hdu-----2491Priest John's Busiest Day(2008 北京现场赛G)
Priest John's Busiest Day Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- Path Sum [LeetCode]
Problem Description: http://oj.leetcode.com/problems/path-sum/ Pretty easy. /** * Definition for bin ...
- vs2010 ctrl+F5闪退解决方法
设置项目的属性页中的“配置属性”->“链接器”->“系统”->“子系统”->“控制台”(即增加“/SUBSYSTEM:CONSOLE”链接选项)
- 【如何快速的开发一个完整的iOS直播app】(推流篇)
前言 在看这篇之前,如果您还不了解直播原理,请查看这篇文章如何快速的开发一个完整的iOS直播app(原理篇) 开发一款直播app,肯定需要流媒体服务器,本篇主要讲解直播中流媒体服务器搭建,并且讲解了如 ...
- PHP 页面编码声明方法详解(header或meta)
php的header来定义一个php页面为utf编码或GBK编码 php页面为utf编码 header("Content-type: text/html; charset=utf-8&quo ...
- 使用C#下载网络文件
下载 /// <summary> /// 下载文件 /// </summary> /// <param name="URL">下载文件地址< ...
- Thinking in java之正则表达式小例子
public static final String POEM= "Twas brilling, and the slithy toves\n" + "Did gyre ...