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