Java easy understand solution


  • 0
    public int getSum(int a, int b) {
        int sum,carry;
    	do{
    		sum = a^b;
    		carry = (a&b)<<1;
    		a = sum;
    		b = carry;
    	}while(b!=0);
    	return a;
    }

Log in to reply
 

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