不使用运算符 +-,计算两整数a 、b之和。

示例:
若 a = 1 ,b = 2,返回 3。

class Solution:
    def getSum(self, a, b):
        """
        :type a: int
        :type b: int
        :rtype: int
        """
      #  return sum([a,b])
        first=a^b
        second=(a&b)<<1
        return sum([first,second])

参考:https://www.jianshu.com/p/3bdba23a0401

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案