💯Less line of code||  C++ ||  VISULAISED ||  🎂🍰✅
\n\nFirst of all happy birthday to all having their birthday today \nand here is cake for u from my side\uD83D\uDE0A\uD83D\uDE09\uD83D\uDE02\uD83D\uDE02\n\nAhh!
```\n\nFirst of all happy birthday to all having their birthday today \nand here is cake for u from my side\uD83D\uDE0A\uD83D\uDE09\uD83D\uDE02\uD83D\uDE02\n\nAhh!! listen pls UPVOTE IF U LIKE THE SOLUTION\n\n\n```\n\n\n![image](https://assets.leetcode.com/users/images/728e2597-702d-484c-9828-7e7dd4d47d7d_1656728794.4693682.png)\n![image](https://assets.leetcode.com/users/images/863e2aca-1158-4e06-a32b-e3419cedeb36_1656728819.212469.png)\n\n\n\nUPVOTE IF U LOVED THE SOLUTION AND ALSO IF THE CAKE WAS TASTIEST\uD83C\uDF82\uD83D\uDE0A\uD83D\uDE02\n\n```\n\n\n\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.\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\nSolution\n\nLets 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\nNow 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\nBecause we want the maximize the area, we must try to maximize the length and height of each piece.\n\nAlgorithm\n\nFind heights of pieces if we only perform the horizontal cuts. Say this array is heights[].\nFind lengths of pieces if we only perform the vertical cuts. Say this arrays is lengths[].\nFind max of heights[] and lengths[].\nMultiply those two max and take mod 10e7.\nReturn the answer\nIs there anything that is still unclear? Let me know and I can elaborate.\n\nThanks\nPlease upvote if you find this helpful, it will be encouraging.\n\nCode\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\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\n\n\nTHANK YOU!!\n\n\n\nUPVOTE IF U TASTED THE CAKE!\n\n\n\n
['C++']