MCPcopy
hub / github.com/HuberTRoy/leetCode / reverse

Method reverse

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

:type x: int :rtype: int

(self, x)

Source from the content-addressed store, hash-verified

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 8

minFlipsMonoIncrMethod · 0.80
isSymmetricMethod · 0.80
insertMethod · 0.80
zigzagLevelOrderMethod · 0.80
sumSubarrayMinsMethod · 0.80
reverseFunction · 0.80
generateMatrixMethod · 0.80
wiggleSortMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected