Ctrl K

Area of the Longest Diagonal

Easy
You are given a list of rectangles rects, where rects[i] = [length, width]. Find the rectangle whose diagonal is the longest and return its area. If several rectangles share the longest diagonal, return the largest area among them.
Example 1
rects=[[2, 9], [6, 7]] → 42

The squared diagonals are 4 + 81 = 85 and 36 + 49 = 85, a tie. Of the areas 18 and 42 we take the larger.

Example 2
rects=[[10, 1], [7, 7]] → 10

The first rectangle has the longer diagonal (√101 vs √98), so the answer is its area, 10.

Example 3
rects=[[4, 4]] → 16
Constraints
  • 1 ≤ len(rects) ≤ 100
  • len(rects[i]) == 2
  • 1 ≤ rects[i][0], rects[i][1] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasySqueeze Repeats Out of a Sorted Array EasyDrop the Unwanted Value EasySlot on a Sorted Shelf EasyAdd One to a Digit Array Easy
loading Python…
Input
rects=[[2, 9], [6, 7]]
Expected
42

Run checks the first 3 tests in your browser. Submit checks all 109 tests on the server, hidden ones included.