C++ 0ms , bit operation ,XOR AND ,very easy


  • 0
    B

    class Solution {
    public:
    int getSum(int a, int b) {
    while(b)
    {
    int c = a^b;
    int d = (a&b)<<1;
    a = c;
    b = d;
    }
    return a;
    }
    };


Log in to reply
 

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