Find the overlapping area between all the rectangles.
Intuition\nFind the overlapping area\n\n# Approach\nThe area of any rectangle can be calculated using the formula: (x_distance) * (y_distance). Since the rectan
# Intuition\nFind the overlapping area\n\n# Approach\nThe area of any rectangle can be calculated using the formula: (x_distance) * (y_distance). Since the rectangles may overlap, we can use Inclusion Exclusion principle to calculate the area as follows:\n\nTotal Area = Area of Rectangle1 + Area of Rectangle2 \u2013 Intersecting area of both the rectangles\n\nFor Rectangle1:\n\nx_distance = abs(L1.x \u2013 R1.x) \ny_distance = abs(L1.y \u2013 R1.y) \nArea of Rectangle1 = x_distance * y_distance\n\nFor Rectangle2:\n\nx_distance = abs(L2.x \u2013 R2.x) \ny_distance = abs(L2.y \u2013 R2.y)\nArea of Rectangle2 = x_distance * y_distance\nFor area of overlapping Rectangle:\n\nx_distance = min(R1.x, R2.x) \u2013 max(L1.x, L2.x)\ny_distance = min(R1.y, R2.y) \u2013 max(L1.y, L2.y)\n\nArea of overlapping rectange = x_distance * y_distance\n\nIf the x_distance or y_distance is negative, then the two rectangles do not intersect. In that case, overlapping area is 0.\n\nTo find the area of overlapping square is min(x_distance, y_distance) **2.\n\n\n# Complexity\n- Time complexity: O(n^2)\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution(object):\n    \n    def overlappingArea(self, l1, r1, l2, r2):\n        x = 0\n        y = 1\n\n        # Area of 1st Rectangle\n        area1 = abs(l1[x] - r1[x]) * abs(l1[y] - r1[y])\n\n        # Area of 2nd Rectangle\n        area2 = abs(l2[x] - r2[x]) * abs(l2[y] - r2[y])\n\n        \'\'\' Length of intersecting part i.e  \n            start from max(l1[x], l2[x]) of  \n            x-coordinate and end at min(r1[x], \n            r2[x]) x-coordinate by subtracting  \n            start from end we get required  \n            lengths \'\'\'\n        x_dist = (min(r1[x], r2[x]) -\n                  max(l1[x], l2[x]))\n\n        y_dist = (min(r1[y], r2[y]) -\n                  max(l1[y], l2[y]))\n        areaI = 0\n        \n        \n        if x_dist > 0 and y_dist > 0:\n            areaI = min(x_dist,y_dist)**2\n            \n        return areaI\n\n    def largestSquareArea(self, bottomLeft, topRight):\n        """\n        :type bottomLeft: List[List[int]]\n        :type topRight: List[List[int]]\n        :rtype: int\n        """\n        max_area=0\n        for ind1 in range(0, len(bottomLeft)):\n            for ind2 in range(ind1+1, len(bottomLeft)):\n                curr_area = self.overlappingArea(bottomLeft[ind1], topRight[ind1], bottomLeft[ind2], topRight[ind2])\n                max_area  = max(max_area, curr_area)\n                \n        return max_area\n\n```
['Python']