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)/俄罗斯套娃信封问题 [russian-doll-envelopes].html
2022-03-29 12:43:11 +08:00

33 lines
1.2 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>给你一个二维整数数组 <code>envelopes</code> ,其中 <code>envelopes[i] = [w<sub>i</sub>, h<sub>i</sub>]</code> ,表示第 <code>i</code> 个信封的宽度和高度。</p>
<p>当另一个信封的宽度和高度都比这个信封大的时候,这个信封就可以放进另一个信封里,如同俄罗斯套娃一样。</p>
<p>请计算 <strong>最多能有多少个</strong> 信封能组成一组“俄罗斯套娃”信封(即可以把一个信封放到另一个信封里面)。</p>
<p><strong>注意</strong>:不允许旋转信封。</p>
&nbsp;
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>envelopes = [[5,4],[6,4],[6,7],[2,3]]
<strong>输出:</strong>3
<strong>解释:</strong>最多信封的个数为 <code>3, 组合为: </code>[2,3] =&gt; [5,4] =&gt; [6,7]。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>envelopes = [[1,1],[1,1],[1,1]]
<strong>输出:</strong>1
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= envelopes.length &lt;= 10<sup>5</sup></code></li>
<li><code>envelopes[i].length == 2</code></li>
<li><code>1 &lt;= w<sub>i</sub>, h<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
</ul>