371. Sum of Two Integers

202401192306
tags: #bit-manipulation

var getSum = function(a, b) {
	let carry = 0;
	while (b) {
		carry = a & b;
		a ^= b;
		b = carry << 1;
	}
	return a;
};

Reference

https://leetcode.com/problems/sum-of-two-integers/