[C++] Simple Sorting Solution Explained, 100% Time, ~100% Space
This problem is relatively easy when you realise that vertical and horizontal cuts do not affect each other directly, so all that you have to do is to find the 
This problem is relatively easy when you realise that vertical and horizontal cuts do not affect each other directly, so all that you have to do is to find the biggest vertical and the biggest vertical gap you can get and then return their product (modulo the constant we are provided in the specs).\n\nTo do so, we will create 3 support variables:\n* `mx` and `my` are where we will store the maximum horizontal and vertical gap, respectively - both initially set to `0`;\n* `prev` is where we will store the position of the previous cut.\n\nThen we will add the full size to each respective series of cuts and then sort them.\n\nLooping with `n` through the sorted series of cuts with `prev`, initially set to `0` (ie: the initial left/upper border), we will update the matching variable for the maximum horizontal/vertical gap to be the largest between its current self and `n - prev`.\n\nOnce done, we will have to just multiply `mx` and `my` (after casting one of them to `long`, but no point in doing it any earlier) and return the result modulo `1000000007` as requested :)\n\nThe code:\n\n```cpp\nclass Solution {\npublic:\n    int maxArea(int h, int w, vector<int>& hc, vector<int>& vc) {\n        int mx = 0, my = 0, prev = 0;\n        // updating and sorting hc and vc\n        hc.push_back(h);\n        vc.push_back(w);\n        sort(begin(hc), end(hc));\n        sort(begin(vc), end(vc));\n        // finding the larger horizontal and vertical gap\n        prev = 0;\n        for (int n: vc) mx = max(mx, n - prev), prev = n;\n        prev = 0;\n        for (int n: hc) my = max(my, n - prev), prev = n;\n        return (long)mx * my % 1000000007;\n    }\n};\n```\n\nMain logic abstracted to helper function to avoid code duplication:\n\n```cpp\nclass Solution {\n    int getMaxGap( vector<int>& base, int maxSize) {\n        // support variables\n        int res = 0, prev = 0;\n        base.push_back(maxSize);\n        sort(begin(base), end(base));\n        // finding the maximum gap\n        for (int n: base) res = max(res, n - prev), prev = n;\n        return res;\n    }\npublic:\n    int maxArea(int h, int w, vector<int>& hc, vector<int>& vc) {\n        return (long)getMaxGap(hc, h) * getMaxGap(vc, w) % 1000000007;\n    }\n};\n```\n\nFinal micro-optimisation to compute the modulo only when necessary:\n\n```cpp\nconstexpr long modVal = 1000000007;\n\nclass Solution {\n    int getMaxGap( vector<int>& base, int maxSize) {\n        // support variables\n        int res = 0, prev = 0;\n        base.push_back(maxSize);\n        sort(begin(base), end(base));\n        // finding the maximum gap\n        for (int n: base) res = max(res, n - prev), prev = n;\n        return res;\n    }\npublic:\n    int maxArea(int h, int w, vector<int>& hc, vector<int>& vc) {\n        long res = (long)getMaxGap(hc, h) * getMaxGap(vc, w);\n        return res < modVal ? res : res % modVal;\n    }\n};\n```
['C', 'C++']