:type x: int :rtype: int
(self, x)
| 31 | |
| 32 | class Solution(object): |
| 33 | def reverse(self, x): |
| 34 | """ |
| 35 | :type x: int |
| 36 | :rtype: int |
| 37 | """ |
| 38 | |
| 39 | # str_x = str(x) |
| 40 | if x < 0: |
| 41 | x = -int(str(abs(x))[::-1]) |
| 42 | else: |
| 43 | x = int(str(abs(x))[::-1]) |
| 44 | |
| 45 | if x > 2**31 or x < -2**31: |
| 46 | return 0 |
| 47 | return x |
no outgoing calls
no test coverage detected