Division key words
- dividend
- divisor
- quotient
- remainder
- modulo operator
Thinking process
negatives?
10 => 1?
overflow?
public class Solution {
public int reverse(int x) {
int result = 0;
while (x != 0) {
if (Math.abs(result) > Integer.MAX_VALUE / 10) {
return 0;
}
int mod = x % 10;
result *= 10;
result += mod;
x /= 10;
}
return result;
}
}