Maximum Area Rectangle With Point Constraints I
You are given an array points where points[i] = [xi, yi] represents the coordinates of a point on an infinite plane.
Your task is to find the maximum area of a rectangle that:
- Can be formed using four of these points as its corners.
- Does not contain any other point inside or on its border.
- Has its edges parallel to the axes.
Return the maximum area that you can obtain, or -1 if no such rectangle is possible.
Example 1
Input
points = [[1,1],[1,3],[3,1],[3,3]]Output
4We can make a rectangle with these 4 points as corners and there is no other point that lies inside or on the border, so the maximum possible area is 4.
Example 2
Input
points = [[1,1],[1,3],[3,1],[3,3],[2,2]]Output
-1The only possible rectangle uses [1,1], [1,3], [3,1], and [3,3], but [2,2] lies inside it, so the result is -1.
Constraints
- 1 <= points.length <= 10
- points[i].length == 2
- 0 <= xi, yi <= 100
- All the given points are unique.