Given two integers a and b, return their sum without using the operators + and -. Pattern focus: Bit Addition. Use XOR for partial sums and AND-shift for carries until the carry becomes zero.
a, b = integers
sum of a and b without using + or -
Example 1:
Input:
a = 1 b = 2
Output:
3
Explanation:
The bitwise sum of 1 and 2 is 3.
Example 2:
Input:
a = -2 b = 3
Output:
1
Explanation:
The algorithm correctly handles negative values.