C++ oneliner using bitset


  • 1
    L
    class Solution {
    public:
        int hammingDistance(int x, int y) {
           return  bitset<32>(x^y).count();
        }
    };
    

Log in to reply
 

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