Sum of Two Integers

2017/12/8 posted in  leetcode

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