Class Solution
java.lang.Object
g0401_0500.s0461_hamming_distance.Solution
461 - Hamming Distance.<p>Easy</p>
<p>The <a href="https://en.wikipedia.org/wiki/Hamming_distance" target="_top">Hamming distance</a> between two integers is the number of positions at which the corresponding bits are different.</p>
<p>Given two integers <code>x</code> and <code>y</code>, return <em>the <strong>Hamming distance</strong> between them</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> x = 1, y = 4</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> 1 (0 0 0 1) 4 (0 1 0 0) \u2191 \u2191 The above arrows point to positions where the corresponding bits are different.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> x = 3, y = 1</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= x, y <= 2<sup>31</sup> - 1</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
hammingDistance
public int hammingDistance(int x, int y)
-