###### Reverse Integer

Reverse digits of an integer.

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

Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!

If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100.

Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases?

For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

class Solution {

public int reverse(Integer x) {

long result=0;
long factor = (x>=0)?1:-1;
long temp = x*factor;

while (temp>0) {
long a = temp%10;
result = result*10+a;
temp=temp/10;
}

if(result>Integer.MAX_VALUE){
return 0;
}
return (int)(result*factor);
}

};

#### reverse-integer(反转整型)

2016-09-26 20:32:14

#### Reverse Integer (python)

2016-07-03 15:41:01

#### LeetCode7——Reverse Integer

2015-01-26 11:21:12

#### Reverse Integer -- LeetCode

2014-02-27 05:39:30

#### 7. Reverse Integer 反转int

2016-05-06 09:48:57

#### [LeetCode] 007. Reverse Integer (Easy) (C++/Java/Python)

2015-02-28 00:17:09

#### LeetCode: Reverse Integer (JavaScript)

2015-04-23 20:41:39

#### LeetCode 7 Reverse Integer（翻转整数）

2015-09-23 09:13:52

#### [LeetCode][7]Reverse Integer解析与位运算实现 -Java实现

2016-06-06 15:57:38

#### 7. Reverse Integer [easy] (Python)

2016-07-26 21:50:37

Reverse Integer