mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 02:41:42 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<p>给你一个有序数组 <code>nums</code> ,请你<strong><a href="http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank"> 原地</a></strong> 删除重复出现的元素,使每个元素 <strong>最多出现两次</strong> ,返回删除后数组的新长度。</p>
|
||||
<p>给你一个有序数组 <code>nums</code> ,请你<strong><a href="http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank"> 原地</a></strong> 删除重复出现的元素,使得出现次数超过两次的元素<strong>只出现两次</strong> ,返回删除后数组的新长度。</p>
|
||||
|
||||
<p>不要使用额外的数组空间,你必须在 <strong><a href="https://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank">原地 </a>修改输入数组 </strong>并在使用 O(1) 额外空间的条件下完成。</p>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
<p><strong>说明:</strong></p>
|
||||
|
||||
@@ -18,19 +18,19 @@ int len = removeDuplicates(nums);
|
||||
|
||||
// 在函数里修改输入数组对于调用者是可见的。
|
||||
// 根据你的函数返回的长度, 它会打印出数组中<strong> 该长度范围内</strong> 的所有元素。
|
||||
for (int i = 0; i < len; i++) {
|
||||
print(nums[i]);
|
||||
for (int i = 0; i < len; i++) {
|
||||
print(nums[i]);
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [1,1,1,2,2,3]
|
||||
<strong>输出:</strong>5, nums = [1,1,2,2,3]
|
||||
<strong>解释:</strong>函数应返回新长度 length = <strong><code>5</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>1, 1, 2, 2,</code></strong> <strong>3 </strong>。 不需要考虑数组中超出新长度后面的元素。
|
||||
<strong>解释:</strong>函数应返回新长度 length = <strong><code>5</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>1, 1, 2, 2, 3</code></strong>。 不需要考虑数组中超出新长度后面的元素。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
@@ -38,15 +38,15 @@ for (int i = 0; i < len; i++) {
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [0,0,1,1,1,1,2,3,3]
|
||||
<strong>输出:</strong>7, nums = [0,0,1,1,2,3,3]
|
||||
<strong>解释:</strong>函数应返回新长度 length = <strong><code>7</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>0</code></strong>, <strong>0</strong>, <strong>1</strong>, <strong>1</strong>, <strong>2</strong>, <strong>3</strong>, <strong>3 。</strong> 不需要考虑数组中超出新长度后面的元素。
|
||||
<strong>解释:</strong>函数应返回新长度 length = <strong><code>7</code></strong>, 并且原数组的前五个元素被修改为 <strong><code>0, 0, 1, 1, 2, 3, 3</code></strong>。不需要考虑数组中超出新长度后面的元素。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li>
|
||||
<li><code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code></li>
|
||||
<li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li>
|
||||
<li><code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code></li>
|
||||
<li><code>nums</code> 已按升序排列</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user