1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数字小镇中的捣蛋鬼 [the-two-sneaky-numbers-of-digitville].html
2024-09-19 09:27:23 +08:00

55 lines
1.8 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>数字小镇 Digitville 中,存在一个数字列表 <code>nums</code>,其中包含从 <code>0</code><code>n - 1</code> 的整数。每个数字本应 <strong>只出现一次</strong>,然而,有 <strong>两个 </strong>顽皮的数字额外多出现了一次,使得列表变得比正常情况下更长。</p>
<p>为了恢复 Digitville 的和平,作为小镇中的名侦探,请你找出这两个顽皮的数字。</p>
<p>返回一个长度为 2 的数组,包含这两个数字(顺序任意)。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [0,1,1,0]</span></p>
<p><strong>输出:</strong> <span class="example-io">[0,1]</span></p>
<p><strong>解释:</strong></p>
<p>数字 0 和 1 分别在数组中出现了两次。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [0,3,2,1,3,2]</span></p>
<p><strong>输出:</strong> <span class="example-io">[2,3]</span></p>
<p><strong>解释: </strong></p>
<p>数字 2 和 3 分别在数组中出现了两次。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">nums = [7,1,5,4,3,4,6,0,9,5,8,2]</span></p>
<p><strong>输出:</strong> <span class="example-io">[4,5]</span></p>
<p><strong>解释: </strong></p>
<p>数字 4 和 5 分别在数组中出现了两次。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= n &lt;= 100</code></li>
<li><code>nums.length == n + 2</code></li>
<li><code>0 &lt;= nums[i] &lt; n</code></li>
<li>输入保证 <code>nums</code><strong> 恰好 </strong>包含两个重复的元素。</li>
</ul>