Posted on

Description

Submission

class Solution {
public:
    int hammingDistance(int x, int y) {
        int ret = 0;

        for(int i = 0; i < 32; ++i) {
            ret += ((x>>i)&1) ^ ((y>>i)&1);
        }

        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *