My solution

  • 0

    Re: Solution in Python

    class Solution:      
         def reverse(self, x):
        :type x: int
        :rtype: int
        x = str(x)
        if len(x) <=1:
            return int(x)
        pref =''
        if not x[0].isdigit():
            pref= x[0]
            x = x[1:]
        x = x[::-1]
        if x[0] == "0":
            res = ''.join([i for i in x[1:]])
            res = ''.join([i for i in x])
        numb = int(pref+res)
        print(numb, type(numb), numb.__sizeof__())
        if numb.__sizeof__() >= 32:
            return 0
        return numb

Log in to reply

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