1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/只出现一次的数字 [single-number].html

41 lines
1.1 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>给你一个 <strong>非空</strong> 整数数组 <code>nums</code> ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p>你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<div class="original__bRMd">
<div>
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 1 </strong></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<pre>
<strong>输入:</strong>nums = [2,2,1]
<strong>输出:</strong>1
2022-03-27 20:56:26 +08:00
</pre>
2023-12-09 18:42:21 +08:00
<p><strong class="example">示例 2 </strong></p>
2022-03-27 20:56:26 +08:00
2023-12-09 18:42:21 +08:00
<pre>
<strong>输入:</strong>nums = [4,1,2,1,2]
<strong>输出:</strong>4
</pre>
<p><strong class="example">示例 3 </strong></p>
<pre>
<strong>输入:</strong>nums = [1]
<strong>输出:</strong>1
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>-3 * 10<sup>4</sup> &lt;= nums[i] &lt;= 3 * 10<sup>4</sup></code></li>
<li>除了某个元素只出现一次以外,其余每个元素均出现两次。</li>
</ul>
</div>
</div>