C++ Use helper struct to simplify problem | O(n^2)
c++\nclass Solution {\n  struct Rectangle {\n    int xl, xr;\n    int yb, yt;\n    \n    Rectangle() : xl(0), yb(0), xr(0), yt(0) {}\n    Rectangle(int a, int b
```c++\nclass Solution {\n  struct Rectangle {\n    int xl, xr;\n    int yb, yt;\n    \n    Rectangle() : xl(0), yb(0), xr(0), yt(0) {}\n    Rectangle(int a, int b, int c, int d) : xl(a), yb(b), xr(c), yt(d) {}\n    \n    inline int width() const { return abs(xr - xl); }\n    inline int height() const { return abs(yt - yb); }\n    \n\t// Check if the rectangles intersect and store the intersecting rectangle in region\n    inline bool intersects(const Rectangle& other, Rectangle& region) const {\n\t  // rectangles must not overlap if the left side is to the right of the right side of the other and vice versa\n\t  // similarly for the top and bottom\n      if (xl > other.xr || yb > other.yt ||\n          other.xl > xr || other.yb > yt) return false;\n\t  // the intersecting region must be maximum of the bottom left coords and the minimum of the top right coords\n      region = Rectangle(max(xl, other.xl), max(yb, other.yb), min(xr, other.xr), min(yt, other.yt));\n      return true;\n    }\n  };\npublic:\n    long long largestSquareArea(vector<vector<int>>& bottomLeft, vector<vector<int>>& topRight) {\n      int n = bottomLeft.size();\n      long long res = 0;\n      Rectangle region;\n\t  // check every unique pair of rectangles - O(n^2) pairs\n      for (int i = 0; i < n; i++) {\n        Rectangle a(bottomLeft[i][0], bottomLeft[i][1], topRight[i][0], topRight[i][1]);\n        for (int j = i + 1; j < n; j++) {          \n          Rectangle b(bottomLeft[j][0], bottomLeft[j][1], topRight[j][0], topRight[j][1]);\n          if (a.intersects(b, region)) {\n\t\t    // the largest intersecting square must have dimensions of the smaller of the width and height\n            long long dim = min(region.width(), region.height());\n            res = max(dim, res);\n          }\n        }\n      }\n\t  // Return the area of the square with the largest dimension \n      return res*res;\n    }\n};\n```
['C']