Algorithms
Easy
10035
3251
Maximum Area of Longest Diagonal Rectangle
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 the 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: 48
Explanation: 
For index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487.
For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.
So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.

Example 2:

Input: dimensions = [[3,4],[4,3]]
Output: 12
Explanation: Length of diagonal is the same for both which is 5, so maximum area = 12.


Constraints:

1 <= dimensions.length <= 100
dimensions[i].length == 2
1 <= dimensions[i][0], dimensions[i][1] <= 100
"""
class Solution:
    def areaOfMaxDiagonal(self, dimensions: List[List[int]]) -> int:
        
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 the 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: 48
Explanation: 
For index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487.
For index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.
So, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.

Example 2:

Input: dimensions = [[3,4],[4,3]]
Output: 12
Explanation: Length of diagonal is the same for both which is 5, so maximum area = 12.


Constraints:

1 <= dimensions.length <= 100
dimensions[i].length == 2
1 <= dimensions[i][0], dimensions[i][1] <= 100


Please complete the code below to solve above prblem:
```python
class Solution:
    def areaOfMaxDiagonal(self, dimensions: List[List[int]]) -> int:
        
```

my_solution = Solution()

test_input = { "dimensions": [[9,3],[8,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 48

test_input = { "dimensions": [[3,4],[4,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 12

test_input = { "dimensions": [[4,10],[4,9],[9,3],[10,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[2,6],[5,1],[3,10],[8,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 30

test_input = { "dimensions": [[3,7],[2,10],[3,4],[9,9],[5,10]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[10,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 40

test_input = { "dimensions": [[9,9],[1,8],[10,5],[2,8],[6,3],[7,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[10,3],[5,9],[8,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 30

test_input = { "dimensions": [[2,7],[3,2],[3,3],[10,4],[5,3],[8,10],[8,8],[4,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[1,10],[3,10],[4,4],[2,6],[6,3],[6,4],[9,1],[6,1],[2,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 30

test_input = { "dimensions": [[4,7],[10,10],[3,7],[9,1],[5,7],[3,9],[10,4],[4,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[1,1],[6,8],[6,9],[7,2],[6,8],[1,3],[3,1],[1,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 54

test_input = { "dimensions": [[6,6],[1,3],[8,10],[10,1],[3,10],[7,7],[10,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[6,5],[8,6],[2,10],[8,1],[9,2],[3,5],[3,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 20

test_input = { "dimensions": [[5,1],[4,9],[9,1],[5,8],[2,9],[3,2],[10,10],[5,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[8,3],[9,10],[7,7],[6,5],[6,9],[9,10],[5,10]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[6,10],[8,6],[10,1],[7,10],[10,10],[9,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[9,5],[9,2],[2,2],[8,9],[5,7],[8,10],[3,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[3,9],[9,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 45

test_input = { "dimensions": [[10,10],[5,5],[3,2],[2,6],[3,1],[10,7],[4,8],[7,9],[9,9],[1,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[2,3],[3,5],[2,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 15

test_input = { "dimensions": [[4,4],[7,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 49

test_input = { "dimensions": [[7,5],[9,6],[9,4],[5,7],[2,6],[10,3],[9,9],[9,4],[8,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[5,1],[9,1],[7,1],[7,1],[3,1],[10,7],[9,1],[7,2],[4,6],[3,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 70

test_input = { "dimensions": [[8,4],[7,4],[1,5],[7,8],[5,6],[5,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 56

test_input = { "dimensions": [[5,10],[3,7],[8,6],[8,6],[5,9],[10,5],[7,8],[1,9],[2,5],[6,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 50

test_input = { "dimensions": [[9,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 36

test_input = { "dimensions": [[7,6],[2,8],[9,6],[1,10],[5,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 54

test_input = { "dimensions": [[4,2],[1,6],[2,1],[4,10],[10,1],[7,5],[8,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 40

test_input = { "dimensions": [[1,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 4

test_input = { "dimensions": [[9,4],[6,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 36

test_input = { "dimensions": [[7,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 35

test_input = { "dimensions": [[1,9],[9,7],[8,4],[6,6],[7,8],[4,6],[7,4],[9,9],[9,8],[8,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[3,8],[6,3],[5,2],[3,7],[1,3],[9,8],[4,2],[3,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 72

test_input = { "dimensions": [[5,4],[2,4],[8,5],[8,4],[1,2],[6,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 40

test_input = { "dimensions": [[7,2],[4,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 14

test_input = { "dimensions": [[8,10],[5,2],[4,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[9,2],[5,6],[4,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 18

test_input = { "dimensions": [[3,8],[2,9],[7,7],[1,5],[1,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 49

test_input = { "dimensions": [[6,2],[8,2],[6,8],[7,6],[1,2],[6,8],[10,9],[2,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[3,8],[4,1],[5,2],[2,6],[4,9],[10,6],[6,10],[3,4],[6,6],[4,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[5,5],[3,8],[2,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 24

test_input = { "dimensions": [[8,1],[5,8],[3,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 40

test_input = { "dimensions": [[2,8],[8,1],[7,10],[5,7],[2,4],[3,10],[2,10],[7,10],[5,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 70

test_input = { "dimensions": [[3,10],[1,3],[10,5],[5,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 50

test_input = { "dimensions": [[10,6],[4,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[7,8],[8,6],[10,10],[6,7],[7,10]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[7,2],[7,3],[4,6],[4,4],[7,8],[2,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 56

test_input = { "dimensions": [[4,7],[3,1],[1,10],[4,2],[4,10],[8,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 64

test_input = { "dimensions": [[1,8],[4,3],[7,7],[10,6],[5,5],[1,3],[9,1],[8,3],[3,2],[5,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[6,7],[1,7],[5,10],[10,1],[8,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 50

test_input = { "dimensions": [[3,5],[2,7],[4,4],[4,9],[7,6],[2,4],[5,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 36

test_input = { "dimensions": [[8,8],[6,10],[6,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[10,2],[3,3],[5,9],[3,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 45

test_input = { "dimensions": [[4,3],[4,1],[8,9],[10,1],[2,7],[7,7],[9,3],[8,6],[1,5],[8,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 72

test_input = { "dimensions": [[6,8],[2,3],[4,9],[1,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 48

test_input = { "dimensions": [[1,6],[2,10],[1,5],[9,3],[9,1],[2,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 20

test_input = { "dimensions": [[6,5],[7,10],[1,2],[10,3],[4,2],[4,8],[5,10],[5,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 70

test_input = { "dimensions": [[1,2],[1,2],[2,4],[9,9],[3,8],[3,9],[2,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[4,4],[6,1],[1,10],[10,7],[10,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 70

test_input = { "dimensions": [[3,2],[2,8],[10,9],[9,8],[2,2],[9,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[4,10],[9,6],[4,10],[6,7],[2,3],[7,9],[9,2],[1,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 63

test_input = { "dimensions": [[7,4],[10,2],[10,8],[4,9],[4,9],[10,3],[5,4],[4,5],[10,6],[3,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[2,5],[7,4],[5,3],[2,4],[3,10],[3,5],[4,5],[4,4],[6,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 30

test_input = { "dimensions": [[3,2],[7,10],[8,10],[7,4],[6,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[3,8],[4,5],[3,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 24

test_input = { "dimensions": [[6,8],[9,9],[1,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[8,1],[7,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 35

test_input = { "dimensions": [[10,6],[5,1],[9,5],[5,7],[5,8],[6,5],[8,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[8,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 48

test_input = { "dimensions": [[5,2],[5,9],[9,5],[5,5],[8,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 45

test_input = { "dimensions": [[7,8],[9,9],[3,5],[8,1],[1,3],[8,2],[8,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 81

test_input = { "dimensions": [[3,10],[6,8],[4,5],[8,1],[7,2],[9,8],[3,7],[3,3],[9,10]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[1,1],[8,7],[4,6],[5,2],[5,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 56

test_input = { "dimensions": [[6,2],[8,4],[8,6],[2,10],[6,1],[9,8],[10,8],[10,10],[5,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[10,2],[9,7],[4,2],[8,6],[9,10],[10,7],[7,5],[5,10],[5,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[1,4],[7,2],[2,6],[7,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 49

test_input = { "dimensions": [[2,5],[10,10],[4,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[2,10],[10,4],[3,9],[6,10],[2,10],[10,1],[4,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[3,6],[5,4],[9,5],[6,2],[4,4],[7,2],[6,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 45

test_input = { "dimensions": [[1,1],[1,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 7

test_input = { "dimensions": [[1,2],[8,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 64

test_input = { "dimensions": [[3,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 21

test_input = { "dimensions": [[6,7],[1,5],[10,9],[10,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[7,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 56

test_input = { "dimensions": [[2,6],[10,3],[10,5],[1,9],[5,2],[9,10],[7,2],[7,7],[1,10]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[3,4],[8,2],[9,3],[2,9],[6,5],[10,5],[4,1],[8,7],[3,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 50

test_input = { "dimensions": [[7,6],[6,8],[5,7],[1,1],[4,5],[6,10],[9,3],[4,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[1,3],[2,4],[4,9],[10,9],[3,9],[7,5],[2,3],[10,7],[2,3],[1,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[1,8],[6,10],[4,8],[3,8],[4,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 60

test_input = { "dimensions": [[6,5],[3,10],[8,7],[10,10],[2,8],[5,8],[10,8],[9,10],[2,8],[8,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[1,6],[8,3],[6,1],[2,10],[2,5],[3,8]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 20

test_input = { "dimensions": [[7,2],[3,8],[10,10],[7,1],[6,8],[6,7],[10,6],[4,6],[5,7],[10,4]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 100

test_input = { "dimensions": [[9,6]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 54

test_input = { "dimensions": [[8,2],[7,6],[1,4],[1,6],[4,8],[10,9],[9,4],[1,5]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 90

test_input = { "dimensions": [[7,3],[2,5],[7,1],[10,7],[7,4],[8,1]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 70

test_input = { "dimensions": [[9,2]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 18

test_input = { "dimensions": [[9,2],[7,2],[2,7]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 18

test_input = { "dimensions": [[2,8],[10,6],[8,10],[9,9]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 80

test_input = { "dimensions": [[3,3]] }
assert my_solution.areaOfMaxDiagonal(**test_input) == 9