JuniorArray
Maximum Area of Longest Diagonal Rectangle
You are given a 2D 0-indexed integer array dimensions.
For all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of rectangle i.
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.
Example 1
Input
dimensions = [[9,3],[8,6]]Output
48The rectangle at index 1 has the greater diagonal length, so its area is 8 * 6 = 48.
Example 2
Input
dimensions = [[3,4],[4,3]]Output
12Both rectangles have diagonal length 5, so the maximum area among them is 12.
Constraints
- 1 <= dimensions.length <= 100
- dimensions[i].length == 2
- 1 <= dimensions[i][0], dimensions[i][1] <= 100