C++ solution


  • 0
    B

    class Solution {
    public:
    int hammingDistance(int x, int y) {
    int z;
    z = x^y;
    int count = 0;
    for (int i = 0;i<32;i++)
    {
    count += (z>>i)&1;
    }
    return count;
    }
    };


Log in to reply
 

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