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 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>给你一个 <strong>非空</strong> 整数数组 <code>nums</code> ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。</p>
<p>你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。</p>
<div class="original__bRMd">
<div>
<p>&nbsp;</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>&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>