@@ -0,0 +1,1241 @@
+// 7. Reverse Integer%0A/**%0A * Reverse digits of an integer.%0A *%0A * Example1: x = 123, return 321%0A * Example2: x = -123, return -321%0A *%0A * Have you thought about this?%0A * Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!%0A *%0A * If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100.%0A *%0A * Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases?%0A *%0A * For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.%0A *%0A * Update (2014-11-10):%0A * Test cases had been added to test the overflow behavior.%0A *%0A * Tags: Math%0A *%0A * Similar Problems: (E) String to Integer (atoi)%0A *%0A * Author: Xinyue Zhang%0A */%0A%0A%0Apublic class Solution %7B%0A    public int reverse(int x) %7B%0A        int result = 0;%0A        while (x != 0)%0A        %7B%0A            int lastDigit = x %25 10;%0A            int newResult = result * 10 + lastDigit;%0A            if ((newResult - lastDigit) / 10 != result)%0A                return 0;%0A            result = newResult;%0A            x /= 10;%0A        %7D%0A        %0A        return result;%0A    %7D%0A%7D

Add solution for 007 Reverse Integer