C++ one liner using __builtin_popcount


  • 0
    N
    class Solution {
    public:
        int hammingDistance(int x, int y) {
            return __builtin_popcount(x ^ y);
        }
    };
    

Log in to reply
 

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