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)/可以形成最大正方形的矩形数目 [number-of-rectangles-that-can-form-the-largest-square].html
2022-03-29 12:43:11 +08:00

37 lines
1.6 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>rectangles</code> ,其中 <code>rectangles[i] = [l<sub>i</sub>, w<sub>i</sub>]</code> 表示第 <code>i</code> 个矩形的长度为 <code>l<sub>i</sub></code> 、宽度为 <code>w<sub>i</sub></code></p>
<p>如果存在 <code>k</code> 同时满足 <code>k <= l<sub>i</sub></code><code>k <= w<sub>i</sub></code> ,就可以将第 <code>i</code> 个矩形切成边长为 <code>k</code> 的正方形。例如,矩形 <code>[4,6]</code> 可以切成边长最大为 <code>4</code> 的正方形。</p>
<p><code>maxLen</code> 为可以从矩形数组 <code>rectangles</code> 切分得到的 <strong>最大正方形</strong> 的边长。</p>
<p>请你统计有多少个矩形能够切出边长为<em> </em><code>maxLen</code> 的正方形,并返回矩形 <strong>数目</strong></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>rectangles = [[5,8],[3,9],[5,12],[16,5]]
<strong>输出:</strong>3
<strong>解释:</strong>能从每个矩形中切出的最大正方形边长分别是 [5,3,5,5] 。
最大正方形的边长为 5 ,可以由 3 个矩形切分得到。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>rectangles = [[2,3],[3,7],[4,3],[3,7]]
<strong>输出:</strong>3
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= rectangles.length <= 1000</code></li>
<li><code>rectangles[i].length == 2</code></li>
<li><code>1 <= l<sub>i</sub>, w<sub>i</sub> <= 10<sup>9</sup></code></li>
<li><code>l<sub>i</sub> != w<sub>i</sub></code></li>
</ul>