1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/与车相交的点 [points-that-intersect-with-cars].html
2023-09-20 00:01:18 +08:00

32 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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>给你一个下标从 <strong>0</strong> 开始的二维整数数组 <code>nums</code> 表示汽车停放在数轴上的坐标。对于任意下标 <code>i</code><code>nums[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> ,其中 <code>start<sub>i</sub></code> 是第 <code>i</code> 辆车的起点,<code>end<sub>i</sub></code> 是第 <code>i</code> 辆车的终点。</p>
<p>返回数轴上被车 <strong>任意部分</strong> 覆盖的整数点的数目。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [[3,6],[1,5],[4,7]]
<strong>输出:</strong>7
<strong>解释:</strong>从 1 到 7 的所有点都至少与一辆车相交,因此答案为 7 。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [[1,3],[5,8]]
<strong>输出:</strong>7
<strong>解释:</strong>1、2、3、5、6、7、8 共计 7 个点满足至少与一辆车相交,因此答案为 7 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>nums[i].length == 2</code></li>
<li><code><font face="monospace">1 &lt;= start<sub>i</sub>&nbsp;&lt;= end<sub>i</sub>&nbsp;&lt;= 100</font></code></li>
</ul>