❤leetcode,python2❤颠倒整数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22795513/article/details/80655625
class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """

        if str(x)[0] == '-':
            num = int('-'+str(x)[1:][::-1])
        else :
            num = int(str(x)[::-1])

        if num>2**31-1 or num<-2**31:
            return 0
        else:
            return num

猜你喜欢

转载自blog.csdn.net/qq_22795513/article/details/80655625
今日推荐