Imagine you're a city planner looking at a map with building locations marked as points. Your task is to find the smallest rectangular plot of land that can be formed by connecting four of these points, where the rectangle's sides must be parallel to the X and Y axes (no diagonal rectangles allowed!).
Given an array points where points[i] = [xi, yi] represents coordinates on a 2D plane, return the minimum area of any axis-aligned rectangle that can be formed using exactly 4 points from the array. If no such rectangle exists, return 0.
Key insight: A valid rectangle needs exactly 4 points forming two pairs of coordinates - if points (x1,y1), (x1,y2), (x2,y1), and (x2,y2) all exist, they form a rectangle with area |x2-x1| ร |y2-y1|.
Input & Output
Constraints
- 1 โค points.length โค 500
- points[i].length == 2
- 0 โค xi, yi โค 4 ร 104
- All points are unique
- Rectangle sides must be parallel to X and Y axes