class Solution(object): def reverse(self, x): \"\"\" :type x: int :rtype: int \"\"\" negative = False if(x < 0):
you can simply use:
if sum >= pow(2,31)-1: return 0