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)/人口最多的年份 [maximum-population-year].html
2022-03-29 12:43:11 +08:00

32 lines
1.3 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>logs</code> ,其中每个 <code>logs[i] = [birth<sub>i</sub>, death<sub>i</sub>]</code> 表示第 <code>i</code> 个人的出生和死亡年份。</p>
<p>年份 <code>x</code><strong>人口</strong> 定义为这一年期间活着的人的数目。第 <code>i</code> 个人被计入年份 <code>x</code> 的人口需要满足:<code>x</code> 在闭区间 <code>[birth<sub>i</sub>, death<sub>i</sub> - 1]</code> 内。注意,人不应当计入他们死亡当年的人口中。</p>
<p>返回 <strong>人口最多</strong><strong>最早</strong> 的年份。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>logs = [[1993,1999],[2000,2010]]
<strong>输出:</strong>1993
<strong>解释:</strong>人口最多为 1 ,而 1993 是人口为 1 的最早年份。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>logs = [[1950,1961],[1960,1971],[1970,1981]]
<strong>输出:</strong>1960
<strong>解释:</strong>
人口最多为 2 ,分别出现在 1960 和 1970 。
其中最早年份是 1960 。</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= logs.length &lt;= 100</code></li>
<li><code>1950 &lt;= birth<sub>i</sub> &lt; death<sub>i</sub> &lt;= 2050</code></li>
</ul>