2023-12-09 18:42:21 +08:00
|
|
|
|
<p>给你一个整数数组 <code>nums</code> ,除某个元素仅出现 <strong>一次</strong> 外,其余每个元素都恰出现 <strong>三次 。</strong>请你找出并返回那个只出现了一次的元素。</p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>你必须设计并实现线性时间复杂度的算法且使用常数级空间来解决此问题。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums = [2,2,3,2]
|
|
|
|
|
<strong>输出:</strong>3
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums = [0,1,0,1,0,1,99]
|
|
|
|
|
<strong>输出:</strong>99
|
|
|
|
|
</pre>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p> </p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li>
|
|
|
|
|
<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
<li><code>nums</code> 中,除某个元素仅出现 <strong>一次</strong> 外,其余每个元素都恰出现 <strong>三次</strong></li>
|
|
|
|
|
</ul>
|