7
class Solution {
public int reverse(int x) {
int rev = 0;
while(x!=0){
if(revInteger.MAX_VALUE/10){
return 0;
}
int digit = x%10;
x /=10;
rev = rev*10+digit;
}
return rev;
// int rev = 0;
// while (x != 0) {
// if (rev < Integer.MIN_VALUE / 10 || rev > Integer.MAX_VALUE / 10) {
// return 0;
// }
// int digit = x % 10;
// x /= 10;
// rev = rev * 10 + digit;
// }
// return rev;
}
}
这个题目的感悟最多的就是 数学要好好学哇!



