Java - 2 lines :P


  • 2
    N

    Here is my answer:

    public class Solution {
        public int getSum(int a, int b) {
            int tempResult = a & b;
            
            return tempResult == 0 ? a ^ b : getSum(tempResult << 1, a ^ b);
        }
    }
    

Log in to reply
 

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