• + 0 comments

    Here is my C++ solution, you can watch the explanation here : https://youtu.be/yj0yNv6BZa8

    long sumXor(long n) {
        long result = 1;
        while(n) {
            result *= (n % 2) ? 1 : 2;
            n /= 2;
        }
        return result;
    }