python 3 code


  • 0
    A

    This is my code

      class Solution:
          def reverse(self, x):
              s = str(x)
              if "-" in s:
                  s = int("-" + ''.join(s[::-1])[:-1])
                  if s < -2147483647 :
                      return 0
                  else:
                      return s
              else:
                  s = int(''.join(s[::-1]))
                  if s > 2147483647 :
                      return 0
                  else:
                      return s

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.