MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / Solution

Class Solution

String/ReverseInteger.py:32–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30"""
31
32class 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected