3000. Maximum Area of Longest Diagonal Rectangle Easy

@problem@discussion
#Array



1/**
2 * [3000] Maximum Area of Longest Diagonal Rectangle
3 *
4 * You are given a 2D 0-indexed integer array dimensions.
5 * For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle<span style="font-size: 13.3333px;"> i</span>.
6 * Return the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diagonal, return the area of the rectangle having the maximum area.
7 *  
8 * <strong class="example">Example 1:
9 * 
10 * Input: dimensions = [[9,3],[8,6]]
11 * Output: 48
12 * Explanation: 
13 * 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.
14 * For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.
15 * So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.
16 * 
17 * <strong class="example">Example 2:
18 * 
19 * Input: dimensions = [[3,4],[4,3]]
20 * Output: 12
21 * Explanation: Length of diagonal is the same for both which is 5, so maximum area = 12.
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= dimensions.length <= 100
27 * 	<font face="monospace">dimensions[i].length == 2</font>
28 * 	<font face="monospace">1 <= dimensions[i][0], dimensions[i][1] <= 100</font>
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle/
34// discuss: https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn area_of_max_diagonal(dimensions: Vec<Vec<i32>>) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_3000() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.