1. 程式人生 > >LeetCode int數字倒置,快於99%的

LeetCode int數字倒置,快於99%的

class Solution:
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        temp = 1
        if x<0:
            temp = -1
            x = -x
        output = int(str(x)[::-1])
        if output-(2**31-1)>0:
            return 0
        return output*temp