mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
47 lines
1.5 KiB
HTML
47 lines
1.5 KiB
HTML
<p>给定一个 <strong>无重复元素</strong> 的 <strong>有序</strong> 整数数组 <code>nums</code> 。</p>
|
||
|
||
<p>返回 <em><strong>恰好覆盖数组中所有数字</strong> 的 <strong>最小有序</strong> 区间范围列表 </em>。也就是说,<code>nums</code> 的每个元素都恰好被某个区间范围所覆盖,并且不存在属于某个范围但不属于 <code>nums</code> 的数字 <code>x</code> 。</p>
|
||
|
||
<p>列表中的每个区间范围 <code>[a,b]</code> 应该按如下格式输出:</p>
|
||
|
||
<ul>
|
||
<li><code>"a->b"</code> ,如果 <code>a != b</code></li>
|
||
<li><code>"a"</code> ,如果 <code>a == b</code></li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [0,1,2,4,5,7]
|
||
<strong>输出:</strong>["0->2","4->5","7"]
|
||
<strong>解释:</strong>区间范围是:
|
||
[0,2] --> "0->2"
|
||
[4,5] --> "4->5"
|
||
[7,7] --> "7"
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>nums = [0,2,3,4,6,8,9]
|
||
<strong>输出:</strong>["0","2->4","6","8->9"]
|
||
<strong>解释:</strong>区间范围是:
|
||
[0,0] --> "0"
|
||
[2,4] --> "2->4"
|
||
[6,6] --> "6"
|
||
[8,9] --> "8->9"
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>0 <= nums.length <= 20</code></li>
|
||
<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>
|
||
<li><code>nums</code> 中的所有值都 <strong>互不相同</strong></li>
|
||
<li><code>nums</code> 按升序排列</li>
|
||
</ul>
|