Solution using regex


#1

def reverse(self, A):
string = “”
str1 = str(A)
a = list(str1)
if (A>=0):
a.reverse()
for i in range(len(a)):
string = string+a[i]
c = int(string)
else:
b = a[1:]
b.reverse()
string = string +a[0]
for i in range(len(b)):
string = string+b[i]
c = int(string)

    if (c >= 2147483647 or c<=-2147483648):
        return 0
    else:
        return c`Preformatted text`