It is very important that 32 bit number. C++ AC but Python failed one positive and one negative case


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

Log in to reply
 

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