#939

Minimum Area Rectangle

specialist · 800 · lc medium +31 · verified · 55.3% accepted · 2,099 likes · top 48%

Description

Given a list of integer-coordinate points points in the XY-plane, find the minimum area of any axis-aligned rectangle (sides parallel to the x- and y-axes) whose four corners are all present in points. Return 0 if no such rectangle exists.

Example 1:

Input: points = [[1,1],[1,3],[3,1],[3,3],[2,2]]
Output: 4

Example 2:

Input: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]]
Output: 2

Code

1
2
3