mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
41 lines
1.1 KiB
HTML
41 lines
1.1 KiB
HTML
<p>给你一个 <strong>非空</strong> 整数数组 <code>nums</code> ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。</p>
|
||
|
||
<p>你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。</p>
|
||
|
||
<div class="original__bRMd">
|
||
<div>
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1 :</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [2,2,1]
|
||
<strong>输出:</strong>1
|
||
</pre>
|
||
|
||
<p><strong class="example">示例 2 :</strong></p>
|
||
|
||
<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>
|