You are given n rectangles on a 2D plane, where each rectangle’s edges are parallel to the X and Y axes.
Each rectangle is defined by two coordinates:
bottomLeft[i] = [a_i, b_i] → bottom-left corner
topRight[i] = [c_i, d_i] → top-right corner
Your task is to find the maximum area of a square that can fit completely inside the intersection region of at least two rectangles.
If no two rectangles intersect, return 0.
Input: bottomLeft = [[1,1],[2,2],[3,1]], topRight = [[3,3],[4,4],[6,6]]
Output: 1
Explanation:
A square of side 1 can fit inside the intersection of rectangles (0,1) or (1,2). Thus, the maximum area = 1 × 1 = 1.
Input: bottomLeft = [[1,1],[1,3],[1,5]], topRight = [[5,5],[5,7],[5,9]]
Output: 4
Explanation:
A square of side 2 fits inside the intersection of rectangles (0,1) or (1,2). Hence, the maximum area = 2 × 2 = 4.
Input: bottomLeft = [[1,1],[2,2],[1,2]], topRight = [[3,3],[4,4],[3,4]]
Output: 1
Explanation:
Each pair of rectangles overlaps with a region allowing a 1×1 square. The largest possible area = 1.
Accepted:
Submission: