标签:max tps The get www solution ref integer min
题目:
样例:
x = 123
,返回 321
x = -123
,返回 -321
实现:
Java实现代码
public class Solution {
/**
* @param n: the integer to be reversed
* @return: the reversed integer
*/
public int reverseInteger(int n) {
// write your code here
boolean negative = n < 0;
if(negative) n = -n;
long r = 0;
while(n>0){
r = r*10 + n%10;
n=n/10;
}
if(negative) r = -r;
if(r>Integer.MAX_VALUE||r<Integer.MIN_VALUE) return 0;
return (int)r;
}
}
标签:max tps The get www solution ref integer min
原文地址:https://www.cnblogs.com/hglibin/p/8979248.html