1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-12 21:52:38 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 12:43:11 +08:00
parent 58bbdfd57c
commit 2b0511d272
10721 changed files with 8123 additions and 8119 deletions

View File

@@ -0,0 +1,32 @@
<p>两个整数之间的 <a href="https://baike.baidu.com/item/%E6%B1%89%E6%98%8E%E8%B7%9D%E7%A6%BB">汉明距离</a> 指的是这两个数字对应二进制位不同的位置的数目。</p>
<p>给你两个整数 <code>x</code><code>y</code>,计算并返回它们之间的汉明距离。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>x = 1, y = 4
<strong>输出:</strong>2
<strong>解释:</strong>
1 (0 0 0 1)
4 (0 1 0 0)
↑ ↑
上面的箭头指出了对应二进制位不同的位置。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>x = 3, y = 1
<strong>输出:</strong>1
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 <= x, y <= 2<sup>31</sup> - 1</code></li>
</ul>