10 line | Easy , Beginner Friendly Detailed  & Well Explained Step By Step Image Solution
IntuitionIt's understood that intersecting just two rectangles is sufficient. Including additional rectangles will either reduce the intersection area or have n
# Intuition

<span style="color:Blue;font-weight:bold">It's understood that intersecting just two rectangles is sufficient. Including additional rectangles will either reduce the intersection area or have no effect.</span>

# Approach
![image.png](https://assets.leetcode.com/users/images/67896087-bc27-48f5-baef-5ed3a20942c7_1742713835.1257653.png)

- Make the plane planar(1D) from 2D. (**Similar to vector projection , here project all parallel lines to same level**)
![image.png](https://assets.leetcode.com/users/images/c4fe2273-0a23-4e97-a169-5e131f31592a_1742715224.2832956.png)

<span style="color:green;font-weight:bold">Now find the overlap in X only ignore Y now:</span>  ` min(c,r) - max(p,a)`


```
FORMULA EXPLANATION: 
    max(p,a) -> Starting point of intersection
    min(c,r) -> Ending point of intersection 

Let's run the assumption formula in all our cases above:

Intersection:
    Case 1: 
        let a = 2 , c = 5 , p = 1 , r = 4
        min(c,r) = 4    max(p,a) = 2
        res = 2

    Case 2: 
        let a = 2 , c = 5, p = 3 , r = 4
        min(c,r) = 4    max(p,a) = 3
        res = 1

    Case 3: 
        let a = 2 , c = 6 , p = 4  , r = 8
        min(c,r) = 6    max(p,a) = 4
        res = 2

Non-Intersection:
    Case 4: 
        let a = 2 , c = 5 , p = 6 , r = 10
        min(c,r) = 5    max(p,a) = 6
        res = -1
        
```
- Similarly do the same for Y.
- Now check :
- - overlap of X : $$min(tj[0],ti[0]) - max(bj[0],bi[0]) $$
- - overlap of Y : $$min(tj[1],ti[1]) - max(bj[1],bi[1]) $$
- - If both X & Y are positive means there is an overlap else no overlap
- When rectangles overlap, determine the minimum side overlap. If this minimum overlap is greater than any previously found minimum overlap, update the answer with this value.
# Complexity
- Time complexity: O(n^2)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def largestSquareArea(self, bottomLeft: List[List[int]], topRight: List[List[int]]) -> int:
        size, ans = len(bottomLeft), 0
        for i in range(size-1):
            bi, ti = bottomLeft[i], topRight[i]
            for j in range(i+1, size):
                bj, tj = bottomLeft[j], topRight[j]
                overlapX = min(tj[0],ti[0]) - max(bj[0],bi[0])
                overlapY = min(tj[1],ti[1]) - max(bj[1],bi[1])
                if overlapX > 0 and overlapY > 0:
                    ans = max(ans, min(overlapX, overlapY))
        return ans*ans
```
['Array', 'Math', 'Geometry', 'Sorting', 'Counting Sort', 'Python', 'C++', 'Java', 'Python3']