Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5b88743

Browse files
committed
Added README.md file for Maximum Area of Longest Diagonal Rectangle
1 parent 6eeae8d commit 5b88743

File tree

1 file changed

+34
-0
lines changed
  • 3251-maximum-area-of-longest-diagonal-rectangle

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle">Maximum Area of Longest Diagonal Rectangle</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
2+
3+
<p>For all indices <code>i</code>, <code>0 &lt;= i &lt; dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size: 13.3333px;"> <code>i</code></span>.</p>
4+
5+
<p>Return <em>the <strong>area</strong> of the rectangle having the <strong>longest</strong> diagonal. If there are multiple rectangles with the longest diagonal, return the area of the rectangle having the <strong>maximum</strong> area.</em></p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> dimensions = [[9,3],[8,6]]
12+
<strong>Output:</strong> 48
13+
<strong>Explanation:</strong>
14+
For index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) &asymp;<!-- notionvc: 882cf44c-3b17-428e-9c65-9940810216f1 --> 9.487.
15+
For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.
16+
So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> dimensions = [[3,4],[4,3]]
23+
<strong>Output:</strong> 12
24+
<strong>Explanation:</strong> Length of diagonal is the same for both which is 5, so maximum area = 12.
25+
</pre>
26+
27+
<p>&nbsp;</p>
28+
<p><strong>Constraints:</strong></p>
29+
30+
<ul>
31+
<li><code>1 &lt;= dimensions.length &lt;= 100</code></li>
32+
<li><code><font face="monospace">dimensions[i].length == 2</font></code></li>
33+
<li><code><font face="monospace">1 &lt;= dimensions[i][0], dimensions[i][1] &lt;= 100</font></code></li>
34+
</ul>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /