天天看点

[LeetCode] Sum of Two Integers 两数之和

Calculate the sum of two integers a and b, but you are not allowed to use the operator <code>+</code> and <code>-</code>.

Example:

Given a = 1 and b = 2, return 3.

Credits:

解法一:

上面的解法可以精简到一行,哈哈,叼不叼?

解法二:

也可以写成迭代的样子,思路都是一样的~

解法三: