Do you like visual explanation? You got it. :-) With 2 code variations.
\n\nKey idea:\nIf we need the area, we must think of lengths and breadths of each cake piece. \n\nAssume\nLENGTH as total horizontal length of the original cake
![image](https://assets.leetcode.com/users/images/d77449f7-8915-4f15-9fb6-6bff8b5e0682_1592971442.3801637.png)\n\n**Key idea**:\nIf we need the area, we must think of lengths and breadths of each cake piece. \n\n**Assume**\nLENGTH as total horizontal length of the original cake.\nHEIGHT as total vertical height of the original cake.\nH as number of horizontal cuts. HCUTS is array of horizontal cuts. \nSimilarly, V as number of vertical cuts and VCUTS is an array of vertical cuts.\n\n**Solution**\n1. Lets only think of horizontal cuts. Each HCUTS[i] would create a piece with length LENGTH and height, say, `heights[i]`.\nAs there are H cuts, there will be (H+1) pieces of length LENGTH.\n\n2. Now each vertical cut VCUTS[i] will cut each of the horizontal pieces that we got in step 1.\nWe already know the height of each piece (step 1), now with each vertical cut, we will know the length of each piece as well.\n\n3. Because we want the maximize the area, we must try to maximize the length and height of each piece.\n\n**Algorithm**\n1. Find heights of pieces if we only perform the horizontal cuts. Say this array is heights[].\n2. Find lengths of pieces if we only perform the vertical cuts. Say this arrays is lengths[].\n3. Find max of heights[] and lengths[].\n4. Multiply those two max and take mod 10e7.\n5. Return the answer\n\n\nIs there anything that is still unclear? Let me know and I can elaborate.\n\n**Thanks**\nPlease upvote if you find this helpful, it will be encouraging.\n\n**Code**\nVariation 1 - Quick to understand, but a bit verbose.\n```\nclass Solution {\npublic:\n    const long long int mod = 1000000007;\n    int maxArea(int hh, int ww, vector<int>& h, vector<int>& v) {\n        // Sort\n        sort(h.begin(), h.end());\n        sort(v.begin(), v.end());\n        \n        \n        // Horizontal\n        vector<int> heights = {h[0]};\n        int nh = h.size();\n        for (int i=1; i<nh; i++) {\n            heights.push_back(h[i]-h[i-1]);\n        }\n        heights.push_back(hh-h[nh-1]);\n        \n        // Vertical\n        vector<int> lengths = {v[0]};\n        int nv = v.size();\n        for (int i=1; i<nv; i++) {\n            lengths.push_back(v[i]-v[i-1]);\n        }\n        lengths.push_back(ww-v[nv-1]);\n        \n        // Take max\n        long long int a = *max_element(heights.begin(), heights.end());\n        long long int b = *max_element(lengths.begin(), lengths.end());\n        \n        // Multiply and return\n        return (int)(a%mod*b%mod);\n    }\n};\n```\n\nVariation 2 - Compact, clean\n```\nclass Solution {\n    int getMax(int hh, vector<int> &h) {\n        sort(h.begin(), h.end()); \n        int nh = h.size();\n        int maxHeight = max(hh-h[nh-1], h[0]);\n        for (int i=1; i<nh; i++) {\n            maxHeight = max(maxHeight, h[i]-h[i-1]);\n        }\n        return maxHeight;\n    }\npublic:\n    int maxArea(int hh, int ww, vector<int>& h, vector<int>& v) {\n        return (int)((long)getMax(hh, h)*getMax(ww, v)%1000000007);\n    }\n};\n```
[]