C# solution: ^ &


  • 0
    B
    public class Solution 
    {
        public int GetSum(int a, int b) 
    	{
    	    if (b == 0) return a;
    	    
            var noCarry = a ^ b;
    		var carry = a & b;
    
    		return GetSum(noCarry, carry << 1);
        }
    }
    

Log in to reply
 

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