问题描述:
方法:
class Solution(object): def getSum(self, a, b): """ :type a: int :type b: int :rtype: int """ lis = [a,b] return sum(lis)
另:
1 class Solution(object): 2 def getSum(self, a, b): 3 """ 4 :type a: int 5 :type b: int 6 :rtype: int 7 """ 8 no_carry_sum=a^b 9 carry_sum=(a&b)<<1 左移一位 3<<1 6 3 & 1 = 1进位 10 return sum([no_carry_sum,carry_sum])
2018-09-27 09:42:03