C++ using std::bitset


  • 0
    W
    class Solution {
    public:
        int hammingDistance(int x, int y) {
            std::bitset<32> bits(x ^ y);
            return bits.count();
        }
    };
    

Log in to reply
 

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