Given an array of points in the X-Y plane, find the minimum area of any rectangle that can be formed from these points.
The key challenge here is that the rectangle's sides don't need to be parallel to the X and Y axes - they can be rotated at any angle! This means we need to consider all possible rectangles, not just axis-aligned ones.
Input: An array points where points[i] = [x_i, y_i] represents a point in 2D space.
Output: The minimum area of any rectangle formed from these points, or 0 if no rectangle can be formed.
Note: Answers within 10^-5 of the actual answer will be accepted due to floating point precision.
Input & Output
Visualization
Time & Space Complexity
We check all combinations of 4 points, which is C(n,4) = O(n^4)
Only using constant extra space for calculations
Constraints
- 1 โค points.length โค 50
- -50 โค xi, yi โค 50
- All points are distinct
- Answers within 10-5 of actual answer will be accepted