(int x)
| 1 | class Solution { |
| 2 | public int reverse(int x) { |
| 3 | if (x == 0) return 0; |
| 4 | long res = 0; |
| 5 | while (x != 0) { |
| 6 | res = res * 10 + x % 10; |
| 7 | if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE) |
| 8 | return 0; |
| 9 | x /= 10; |
| 10 | } |
| 11 | return (int) res; |
| 12 | } |
| 13 | } |
no outgoing calls
no test coverage detected