Math Fundamentals18 sections · 814 units
Open in Course

Minimum Area Rectangle - Insight

Diagonal points approach

For a rectangle with sides parallel to axes, if you know two diagonal corners (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2), the other two corners must be (x1,y2)(x_1, y_2) and (x2,y1)(x_2, y_1).

Store all points in a set for O(1)O(1) lookup. For each pair of points that could be diagonal corners (different xx and yy), check if the other two corners exist.

The area of the rectangle is x2x1×y2y1|x_2 - x_1| \times |y_2 - y_1|. Track the minimum area found.