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)/航班预订统计 [corporate-flight-bookings].html
2022-03-29 12:43:11 +08:00

47 lines
1.8 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>这里有&nbsp;<code>n</code>&nbsp;个航班,它们分别从 <code>1</code><code>n</code> 进行编号。</p>
<p>有一份航班预订表&nbsp;<code>bookings</code> ,表中第&nbsp;<code>i</code>&nbsp;条预订记录&nbsp;<code>bookings[i] = [first<sub>i</sub>, last<sub>i</sub>, seats<sub>i</sub>]</code>&nbsp;意味着在从 <code>first<sub>i</sub></code>&nbsp;<code>last<sub>i</sub></code> <strong>包含</strong> <code>first<sub>i</sub></code><code>last<sub>i</sub></code> )的 <strong>每个航班</strong> 上预订了 <code>seats<sub>i</sub></code>&nbsp;个座位。</p>
<p>请你返回一个长度为 <code>n</code> 的数组&nbsp;<code>answer</code>,里面的元素是每个航班预定的座位总数。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
<strong>输出:</strong>[10,55,45,25,25]
<strong>解释:</strong>
航班编号 1 2 3 4 5
预订记录 1 10 10
预订记录 2 20 20
预订记录 3 25 25 25 25
总座位数: 10 55 45 25 25
因此answer = [10,55,45,25,25]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>bookings = [[1,2,10],[2,2,15]], n = 2
<strong>输出:</strong>[10,25]
<strong>解释:</strong>
航班编号 1 2
预订记录 1 10 10
预订记录 2 15
总座位数: 10 25
因此answer = [10,25]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= bookings.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>bookings[i].length == 3</code></li>
<li><code>1 &lt;= first<sub>i</sub> &lt;= last<sub>i</sub> &lt;= n</code></li>
<li><code>1 &lt;= seats<sub>i</sub> &lt;= 10<sup>4</sup></code></li>
</ul>