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
Inputdimensions = [[9,3],[8,6]]
Output48
The rectangle at index 1 has the greater diagonal length, so its area is 8 * 6 = 48.
Example 2
Inputdimensions = [[3,4],[4,3]]
Output12
Both 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

Asked at 4 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate