371.Sum of Two Integers

https://discuss.leetcode.com/topic/49771/java-simple-easy-understand-solution-with-explanation

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

results matching ""

    No results matching ""