Hey Guys, so I wrote my program as below:
def reverse(self, x): sign = 1 if x < 0: sign *=-1 x = list(str(abs(x))) x = x[::-1] x = int(''.join(x))*sign return x
However for some reason, test case below just wouldn't pass.
I think it has to do with overflow but in python sys.maxint is 9223372036854775807, (in other words, way beyond this test case). I couldn't figured out why its expected output as 0. Please help, thank you!
@thedrizzle43 Hey I figured out last time.
So for an int type, its range is limited from -2^31 to 2^31-1;
so in this case because 9646324351 > 2^31-1, leetcode wants us to output 0.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.