Can anyone point out the mistake in my code?


def reverse(self, A):
if abs(A) <= 2**31-1:
if A<0:
return -int(str(abs(A))[::-1])
return int(str(A)[::-1])
return 0


signed int range is: [-2**31,2**31) (observe closed and open ranges)
So you are missing -2**31 in your code:)
And of course you don’t need to check if it is less than 2**31 since function’s parameter itself is int. Chuck that line out;