Sum of Two Integers without using arithmetic operator and Loops


  • 0
    R
    public int getSum(int a, int b) {
            
            int x=a&b;
            int y=a^b;
            x=x<<1;
            int result = y+x;
            return result;
    }
    

Log in to reply
 

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