mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-11-12 15:25:48 +08:00
update
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<p>给你一个整数数组 <code>nums</code> ,数组由若干 <b>互不相同</b> 的整数组成。</p>
|
||||
|
||||
<p>数组 <code>nums</code> 原本包含了某个范围内的 <strong>所有整数 </strong>。但现在,其中可能 <strong>缺失</strong> 部分整数。</p>
|
||||
|
||||
<p>该范围内的 <strong>最小 </strong>整数和 <strong>最大 </strong>整数仍然存在于 <code>nums</code> 中。</p>
|
||||
|
||||
<p>返回一个 <strong>有序 </strong>列表,包含该范围内缺失的所有整数,并 <strong>按从小到大排序</strong>。如果没有缺失的整数,返回一个 <strong>空 </strong>列表。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong class="example">示例 1:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>输入:</strong> <span class="example-io">nums = [1,4,2,5]</span></p>
|
||||
|
||||
<p><strong>输出:</strong> <span class="example-io">[3]</span></p>
|
||||
|
||||
<p><strong>解释:</strong></p>
|
||||
|
||||
<p>最小整数为 1,最大整数为 5,因此完整的范围应为 <code>[1,2,3,4,5]</code>。其中只有 3 缺失。</p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">示例 2:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>输入:</strong> <span class="example-io">nums = [7,8,6,9]</span></p>
|
||||
|
||||
<p><strong>输出:</strong> <span class="example-io">[]</span></p>
|
||||
|
||||
<p><strong>解释:</strong></p>
|
||||
|
||||
<p>最小整数为 6,最大整数为 9,因此完整的范围为 <code>[6,7,8,9]</code>。所有整数均已存在,因此没有缺失的整数。</p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">示例 3:</strong></p>
|
||||
|
||||
<div class="example-block">
|
||||
<p><strong>输入:</strong> <span class="example-io">nums = [5,1]</span></p>
|
||||
|
||||
<p><strong>输出:</strong> <span class="example-io">[2,3,4]</span></p>
|
||||
|
||||
<p><strong>解释:</strong></p>
|
||||
|
||||
<p>最小整数为 1,最大整数为 5,因此完整的范围应为 <code>[1,2,3,4,5]</code>。缺失的整数为 2、3 和 4。</p>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 100</code></li>
|
||||
<li><code>1 <= nums[i] <= 100</code></li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user