Given two integers a and b, return the sum of the two integers without using the operators + or -.

Input: a = 1, b = 2
Output: 3
Explanation: 1 + 2 = 3, computed using XOR and carry.
Input: a = 2, b = 3
Output: 5
Explanation: 2 (010) XOR 3 (011) = 001, carry = 100; 001 XOR 100 = 101 = 5.

Binary addition works in two steps: XOR gives the sum without carry, and (a & b) << 1 gives the carry. Repeat until there is no carry.

class Solution { public int getSum(int a, int b) { while (b != 0) { int carry = (a & b) << 1; a = a ^ b; b = carry; } return a; } }
Complexity Analysis:

Time complexity: O(1) — bounded by 32 bit positions.
Space complexity: O(1) — constant extra space.