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)/检查是否区域内所有整数都被覆盖 [check-if-all-the-integers-in-a-range-are-covered].html
2022-03-29 12:43:11 +08:00

37 lines
1.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>给你一个二维整数数组 <code>ranges</code> 和两个整数 <code>left</code> 和 <code>right</code> 。每个 <code>ranges[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> 表示一个从 <code>start<sub>i</sub></code> 到 <code>end<sub>i</sub></code> 的 <strong>闭区间</strong> 。</p>
<p>如果闭区间 <code>[left, right]</code> 内每个整数都被 <code>ranges</code> 中 <strong>至少一个</strong> 区间覆盖,那么请你返回 <code>true</code> ,否则返回 <code>false</code> 。</p>
<p>已知区间 <code>ranges[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> ,如果整数 <code>x</code> 满足 <code>start<sub>i</sub> <= x <= end<sub>i</sub></code> ,那么我们称整数<code>x</code> 被覆盖了。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5
<b>输出:</b>true
<b>解释:</b>2 到 5 的每个整数都被覆盖了:
- 2 被第一个区间覆盖。
- 3 和 4 被第二个区间覆盖。
- 5 被第三个区间覆盖。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>ranges = [[1,10],[10,20]], left = 21, right = 21
<b>输出:</b>false
<b>解释:</b>21 没有被任何一个区间覆盖。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= ranges.length <= 50</code></li>
<li><code>1 <= start<sub>i</sub> <= end<sub>i</sub> <= 50</code></li>
<li><code>1 <= left <= right <= 50</code></li>
</ul>