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> </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> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li>
|
|
|
|
|
<li><code>-3 * 10<sup>4</sup> <= nums[i] <= 3 * 10<sup>4</sup></code></li>
|
|
|
|
|
<li>除了某个元素只出现一次以外,其余每个元素均出现两次。</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|