JavaScript solution without "+" operator


  • 0
    J
    var getSum = function(a, b) {
        let and, xor;
        do{
            and = (a & b) << 1;
            xor = a ^ b;        
            a = and, b = xor;        
        } while(and != 0);
            
        return xor;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.