package com.fishercoder.solutions;

/**
 * The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

 Given two integers x and y, calculate the Hamming distance.

 Note:
 0 ≤ x, y < 231.

 Example:

 Input: x = 1, y = 4

 Output: 2

 Explanation:
 1   (0 0 0 1)
 4   (0 1 0 0)
 ↑   ↑

 The above arrows point to positions where the corresponding bits are different.
 */
public class _461 {
	public int hammingDistance(int x, int y) {
		int n = x ^ y;
		int count = 0;
		while (n != 0) {
			count++;
			n &= (n - 1);
		}
		return count;
	}
}

@@ -33,16 +33,44 @@
 s;%0A%0A/**%0A
+ * 461. Hamming Distance%0A *%0A
  * The H
@@ -470,16 +470,50 @@
  _461 %7B%0A
+%09public static class Solution1 %7B%0A%09
 %09public 
@@ -550,16 +550,17 @@
  y) %7B%0A%09%09
+%09
 int n = 
@@ -566,16 +566,17 @@
  x %5E y;%0A
+%09
 %09%09int co
@@ -584,16 +584,17 @@
 nt = 0;%0A
+%09
 %09%09while 
@@ -607,16 +607,17 @@
 0) %7B%0A%09%09%09
+%09
 count++;
@@ -617,16 +617,17 @@
 ount++;%0A
+%09
 %09%09%09n &= 
@@ -639,14 +639,16 @@
 1);%0A
+%09
 %09%09%7D%0A%09%09
+%09
 retu
@@ -657,13 +657,17 @@
  count;%0A
+%09%09%7D%0A
 %09%7D%0A%7D%0A

refactor 461