题目描述请点击查看LeetCode 题目描述
Python3 代码解答如下:
class Solution:
def divide(self, dividend, divisor):
"""
:type dividend: int
:type divisor: int
:rtype: int
"""
a = dividend // divisor
if a < -2**31 or a > 2**31-1:
return 2**31-1
elif a < 0:
return - (abs(dividend) // abs(divisor))
else:
return a