We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c7e25d commit 0c191feCopy full SHA for 0c191fe
src/main/java/com/fishercoder/solutions/_461.java
@@ -1,6 +1,8 @@
1
package com.fishercoder.solutions;
2
3
/**
4
+ * 461. Hamming Distance
5
+ *
6
* The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
7
8
Given two integers x and y, calculate the Hamming distance.
@@ -22,13 +24,15 @@
22
24
The above arrows point to positions where the corresponding bits are different.
23
25
*/
26
public class _461 {
- public int hammingDistance(int x, int y) {
- int n = x ^ y;
27
- int count = 0;
28
- while (n != 0) {
29
- count++;
30
- n &= (n - 1);
+ public static class Solution1 {
+ public int hammingDistance(int x, int y) {
+ int n = x ^ y;
+ int count = 0;
31
+ while (n != 0) {
32
+ count++;
33
+ n &= (n - 1);
34
+ }
35
+ return count;
36
}
- return count;
37
38
0 commit comments