标签:产生 use 适合 not 异或 第一部分 put 左移 加法
Calculate the sum of two integers a and b, but you are not allowed to use the operator +
and -
.
Example 1:
Input: a = 1, b = 2
Output: 3
Example 2:
Input: a = -2, b = 3 Output: 1"思路:
https://leetcode.com/problems/sum-of-two-integers/discuss/167728
class Solution { public int getSum(int a, int b) { return b == 0 ? a : getSum(a ^ b, (a & b) << 1); } }
标签:产生 use 适合 not 异或 第一部分 put 左移 加法
原文地址:https://www.cnblogs.com/wentiliangkaihua/p/11824346.html