Reverse Integer-LeetCode(java实现)
题目描述
此题目较为简单,记得考虑int类型最大值(正负)
class Solution {
public int reverse(int x) {
int result =0;
while(x!=0){
if(x==0|| Math.abs(result)>Integer.MAX_VALUE/10){
return 0;
}else{
result = result * 10 + x %10;
x = x/10;
}
}
return result;
}
}