Maximum-Area Rectangle from Points
Problem statement
Given distinct integer-coordinate points in the plane, choose four of them that form a rectangle. The rectangle's sides do not need to be parallel to the axes.
Return the maximum possible rectangle area. Return 0 when no rectangle can be formed.
Function
maximumRectangleArea(points: int[][]) → longExamples
Example 1
points = [[1,2],[2,1],[1,0],[0,1]]return = 2The four points form a rotated square of area 2.
Example 2
points = [[0,0],[0,2],[3,0],[3,2],[1,1]]return = 6The axis-aligned rectangle with width 3 and height 2 is largest.
Example 3
points = [[0,0],[1,1],[2,3]]return = 0No four points are available to form a rectangle.
Constraints
1 <= points.length <= 500.- Every point contains exactly two integers in
[-40000, 40000]. - All points are distinct.
- The answer fits in a signed 64-bit integer.