Largest Rectangle From Points
Asked at Google
Reported by the problem's creator, not verified
You are given distinct points on a plane with integer coordinates. A rectangle is formed when four of the points are its corners. The rectangle's sides do not have to be parallel to the axes. A square counts as a rectangle.
Examples
Example 1
Input: points =
[[0,0],[0,2],[3,0],[3,2],[1,1]]Output:
6Explanation: The corners (0, 0), (3, 0), (3, 2), (0, 2) form a 3 by 2 rectangle, so the area is 6. The point (1, 1) is not a corner of anything larger.
Example 2
Input: points =
[[1,0],[3,1],[2,3],[0,2],[0,0]]Output:
5Explanation: The four points (1, 0), (3, 1), (2, 3), (0, 2) have sides (2, 1) and (-1, 2): perpendicular and both of length sqrt(5), a square of area 5. (0, 0) is unused.