Solution to LeetCode Reverse Integer problem.
This is a simple implementation question.
public int reverse(int x) { boolean neg = (x < 0); if(neg) x*= -1; int res = 0; while(x != 0){ res *= 10; int div = x / 10; int mod = x % 10; res += mod; x = div; } if(neg) res *= -1; return res; }