clueless coding // TODO: be smarter

LeetCode Hamming Distance: Java Solution



TL;DR Code Solution


public int hammingDistance(int x, int y) {
    int z = x ^ y;
    int counter = 0;
    while (z != 0) {
        counter++;
        z &= z - 1;
    }
    return counter;
}