Compute a + b treating both as 32-bit signed integers, using bitwise reasoning (carry via AND, sum via XOR). The result is guaranteed to fit in a signed 32-bit integer.
One line: two integers a and b.
One line: their sum.
Example 1
Input
3 5
Expected
8
Explanation
3 + 5 = 8, computed with carry and XOR steps.
Example 2
Input
-2 7
Expected
5
Explanation
-2 + 7 = 5, handled with 32-bit two's-complement arithmetic.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →