Very Easy Java Solution Using ^, & and <<


  • 0
    F
    public class Solution {
        public int getSum(int a, int b) {
            while (b != 0) {
                int c = a;
                a = a ^ b;
                b = c & b;
                b <<= 1;
            }
            return a;
        }
    }
    

Log in to reply
 

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