VERY SIMPLE SOLUTION
Intuition\nThe problem involves finding the largest area of a square that can be formed by intersecting two rectangles among given sets of rectangles. Essential
# Intuition\nThe problem involves finding the largest area of a square that can be formed by intersecting two rectangles among given sets of rectangles. Essentially, we need to identify pairs of rectangles that intersect and determine the maximum square area within their intersection.\n\n- **How to find if 2 rectangles are intersecting ??**\n![Screenshot 2024-02-26 195704.png](https://assets.leetcode.com/users/images/cb910dcb-4ff7-47d3-a64b-9a9075f8f899_1708958500.1621182.png)\n\nConsider a line topRight and a line bottomLeft. To find the intersection of the two lines we have to calculate max(m1,x1) and the min(x2,l2). If the max(l1,x1)<min(x2,l2) then we can say that the line is intersecting.\n\nHere you can consider x1,x2 as the x coodinates of topRight rectangle and l1,l2 as the x coordinates of bottomLeft rectangle. We have to do the same with the y coordinates. If the max(m1,x1)<min(x2,m2) then we can say that the line is intersecting in y axis.\n\nWhen both the consitions satisfy then we can say that 2 recatngles are intersecting.\n\n\n\n# Approach\n- **Iterative Comparison**: The solution iterates over each pair of rectangles to check for intersections.\n- **Intersection Check**: For each pair of rectangles, it checks whether they intersect. If they do, it calculates the dimensions of the intersection rectangle.\n- **Maximum Square Area**: Within the intersection rectangle, the solution calculates the maximum square area possible by taking the minimum of the width and height of the intersection.\n- **Updating Maximum Area**: It updates the maximum square area encountered so far.\n# Complexity\n- Time complexity: O(N^2)\n- Space complexity: O(1)\n- \n```cpp []\nclass Solution {\npublic:\n    long largestSquareArea(vector<vector<int>>& bottomLeft, vector<vector<int>>& topRight) {\n        long maxArea = 0;\n        for (int i = 0; i < bottomLeft.size(); i++) {\n            for (int j = i + 1; j < bottomLeft.size(); j++) {\n                int x1 = max(bottomLeft[i][0], bottomLeft[j][0]);\n                int y1 = max(bottomLeft[i][1], bottomLeft[j][1]);\n                int x2 = min(topRight[i][0], topRight[j][0]);\n                int y2 = min(topRight[i][1], topRight[j][1]);\n\n                // checking if they intersect\n                if (x1 < x2 && y1 < y2) {\n                    long minSide = min(x2 - x1, y2 - y1);\n                    maxArea = max(maxArea, minSide * minSide);\n                }\n            }\n        }\n        return maxArea;\n    }\n};\n```\n```java []\nclass Solution {\n    public long largestSquareArea(int[][] bottomLeft, int[][] topRight) {\n        long maxArea=0;\n        for(int i=0;i<bottomLeft.length;i++){\n            for(int j=i+1;j<bottomLeft.length;j++){\n                int x1=Math.max(bottomLeft[i][0],bottomLeft[j][0]);\n                int y1=Math.max(bottomLeft[i][1],bottomLeft[j][1]);\n                int x2=Math.min(topRight[i][0],topRight[j][0]);\n                int y2=Math.min(topRight[i][1],topRight[j][1]);\n\n                // checking if they intersect\n                if (x1 < x2 && y1 < y2){\n                    long min=Math.min(x2-x1,y2-y1);\n                    maxArea=Math.max(maxArea,min*min);\n                }\n\n            }\n        }\n        return maxArea;\n    }\n}\n```\n```python []\nclass Solution:\n    def largestSquareArea(self, bottomLeft, topRight):\n        maxArea = 0\n        for i in range(len(bottomLeft)):\n            for j in range(i + 1, len(bottomLeft)):\n                x1 = max(bottomLeft[i][0], bottomLeft[j][0])\n                y1 = max(bottomLeft[i][1], bottomLeft[j][1])\n                x2 = min(topRight[i][0], topRight[j][0])\n                y2 = min(topRight[i][1], topRight[j][1])\n\n                # checking if they intersect\n                if x1 < x2 and y1 < y2:\n                    minSide = min(x2 - x1, y2 - y1)\n                    maxArea = max(maxArea, minSide * minSide)\n        return maxArea\n```\n![main-qimg-dd19ad82f9afcc414cdfc8ded048648e-lq.jpg](https://assets.leetcode.com/users/images/18460942-2ae5-4661-a1d4-144d01f0f76a_1708834412.2301962.jpeg)\n\n
['Array', 'Math', 'Geometry', 'Matrix', 'Python', 'C++', 'Java']