Concise Java Iterative Sol.


  • 0
    O
        public int getSum(int a, int b) {
            for (; b != 0; b <<= 1) {
                int tmp = a ^ b;
                b = a & b;
                a = tmp;
            }
            return a;
        }
    

Log in to reply
 

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