LeetCode "Sum of Two Integers"

Fun with bits - carries etc.

class Solution {
public:
    int getSum(int a, int b) {
        if(!b) return a;
        return getSum(a ^ b, (a & b) << 1);
    }
};
原文地址:https://www.cnblogs.com/tonix/p/5648699.html