checking integer overflow in python

后端 未结 6 626
故里飘歌
故里飘歌 2021-02-05 08:01
class Solution(object):
    def reverse(self, x):
        \"\"\"
        :type x: int
        :rtype: int
        \"\"\"
        negative = False
        if(x < 0):
          


        
6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 08:07

    if sum > ((1 << 31) - 1):
        return 0
    else:
        if negative == True:
          sum = -sum
          return sum
    

提交回复
热议问题