package com.fishercoder.solutions;

/**
 * 461. Hamming Distance
 *
 * 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 static class Solution1 {
		public int hammingDistance(int x, int y) {
			int n = x ^ y;
			int count = 0;
			while (n != 0) {
				count++;
				n &= (n - 1);
			}
			return count;
		}
	}
}

@@ -33,429 +33,8 @@
 s;%0A%0A
-/**%0A * 461. Hamming Distance%0A *%0A * The Hamming distance between two integers is the number of positions at which the corresponding bits are different.%0A%0A Given two integers x and y, calculate the Hamming distance.%0A%0A Note:%0A 0 %E2%89%A4 x, y %3C 231.%0A%0A Example:%0A%0A Input: x = 1, y = 4%0A%0A Output: 2%0A%0A Explanation:%0A 1   (0 0 0 1)%0A 4   (0 1 0 0)%0A %E2%86%91   %E2%86%91%0A%0A The above arrows point to positions where the corresponding bits are different.%0A */%0A
 publ
@@ -49,17 +49,20 @@
  _461 %7B%0A
-%09
+    
 public s
@@ -85,18 +85,24 @@
 tion1 %7B%0A
-%09%09
+        
 public i
@@ -136,19 +136,28 @@
 nt y) %7B%0A
-%09%09%09
+            
 int n = 
@@ -163,19 +163,28 @@
  x %5E y;%0A
-%09%09%09
+            
 int coun
@@ -190,19 +190,28 @@
 nt = 0;%0A
-%09%09%09
+            
 while (n
@@ -223,66 +223,117 @@
 ) %7B%0A
-%09%09%09%09count++;%0A%09%09%09%09n &= (n - 1);%0A%09%09%09%7D%0A%09%09%09return count;%0A%09%09%7D%0A%09
+                count++;%0A                n &= (n - 1);%0A            %7D%0A            return count;%0A        %7D%0A    
 %7D%0A%7D%0A

refactor 461