(int x)
| 10 | */ |
| 11 | public class Solution { |
| 12 | public int reverse(int x) { |
| 13 | long res = 0; |
| 14 | for (; x != 0; x /= 10) |
| 15 | res = res * 10 + x % 10; |
| 16 | return res > Integer.MAX_VALUE || res < Integer.MIN_VALUE ? 0 : (int) res; |
| 17 | } |
| 18 | |
| 19 | public static void main(String[] args) { |
| 20 | Solution solution = new Solution(); |