This was a classic Geometry problem. All I needed to do was in three steps:
- Initialize a
maxAreavalue - Compare every rectangle with one another (a nested loop)
- For each rectangle pair, Check if they intersect (the minimum of the rights minus the maximum of the lefts > 0)
- If intersects, find the largest possible square (square of the smaller side of the intersection boundary)
- Update
maxAreawith the maximum of this value in previous step andmaxArea

