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-area-of-longest-diagonal-rectangle].html
2024-01-09 10:57:06 +08:00

37 lines
1.6 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>dimensions</code></p>
<p>对于所有下标 <code>i</code><code>0 &lt;= i &lt; dimensions.length</code><code>dimensions[i][0]</code> 表示矩形 <span style="font-size: 13.3333px;"> <code>i</code></span> 的长度,而 <code>dimensions[i][1]</code> 表示矩形 <span style="font-size: 13.3333px;"> <code>i</code></span> 的宽度。</p>
<p>返回对角线最 <strong></strong>的矩形的<strong> 面积 </strong>。如果存在多个对角线长度相同的矩形,返回面积最<strong></strong>的矩形的面积。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>dimensions = [[9,3],[8,6]]
<strong>输出:</strong>48
<strong>解释:</strong>
下标 = 0长度 = 9宽度 = 3。对角线长度 = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈<!-- notionvc: 882cf44c-3b17-428e-9c65-9940810216f1 --> 9.487。
下标 = 1长度 = 8宽度 = 6。对角线长度 = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10。
因此,下标为 1 的矩形对角线更长,所以返回面积 = 8 * 6 = 48。
</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>dimensions = [[3,4],[4,3]]
<strong>输出:</strong>12
<strong>解释:</strong>两个矩形的对角线长度相同,为 5所以最大面积 = 12。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= dimensions.length &lt;= 100</code></li>
<li><code>dimensions[i].length == 2</code></li>
<li><code>1 &lt;= dimensions[i][0], dimensions[i][1] &lt;= 100</code></li>
</ul>