While loop c++ solution


  • 0
    J
    class Solution {
    public:
      int getSum(int a, int b) {
        int c = a & b; 
        int d = a | b;
        int d1;
        while (c != 0) {
            d1 = (d & ~c) | (c << 1);
            c = (d & ~c) & (c << 1);
            d = d1;
        }
        return d;
      }
    };
    

    using while loop


Log in to reply
 

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