Sum of Two Integers

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

Example

Example 1

1
2
Input: a = 1, b = 2
Output: 3

Solution

See Method 1 and Method 2 of Sum of two numbers using only bitwise operators, and here is the video explaining this method in detail. Please check it out: