✔️ C++ || EXPLAINED || ; ]
UPVOTE IF HELPFuul\n\nWhat are we looking for ?\nWe need to maximize the area of the cut.\n\nGoing for nested loops will give Time Limit Exceeded.\n\nBut we kno
**UPVOTE IF HELPFuul**\n\nWhat are we looking for ?\nWe need to **maximize** the area of the cut.\n\nGoing for nested loops will give Time Limit Exceeded.\n\nBut we know ```area  = lenght * breadth```\nHence we can maximize length and breadth both in **O ( N LOGN )** and multiply them to get the answer.\n\nIT CAN DEDUCED THAT for every length of cut piece, all variable breadths are avaliable. Hence getting **max** of both will give answer.\n\n\n**IMPLEMENTAION**\n* Add ```0``` and ```size of h or w``` to respective array.\n* Sort the array.\n* Loop to find **maximum consecutive distance**.\nMaximum consecutive Distance will be max length for verticalCuts and breadth for horizontalCuts.\n* Return ```(max length * max breadth) % 1000000007```\n\n\n**If you do not want to append** ```ZERO```**, remove that line of code, and initialize the value of** ```l, b``` **as minimum of** ```verticalCut, horizontalCut``` **respectively.**\n\n**UPVOTE IF HELPFuuL**\n\n```\nclass Solution {\npublic:\n    int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {\n        \n        horizontalCuts.push_back(0);\n        horizontalCuts.push_back(h);\n        \n        verticalCuts.push_back(0);\n        verticalCuts.push_back(w);\n        \n        sort(horizontalCuts.begin(),horizontalCuts.end());\n        sort(verticalCuts.begin(),verticalCuts.end());\n        \n        long long int l = 0, b = 0;\n        \n        for(int i=1; i<horizontalCuts.size(); i++){\n            if (b < horizontalCuts[i] - horizontalCuts[i-1]){\n                b = horizontalCuts[i] - horizontalCuts[i-1];\n            }\n        }\n        for (int i=1; i<verticalCuts.size(); i++){\n            if(l < verticalCuts[i] - verticalCuts[i-1]){\n                l = verticalCuts[i] - verticalCuts[i-1];\n            }\n        }\n        return (l*b)%1000000007;\n        \n    }\n};\n```\n![image](https://assets.leetcode.com/users/images/0f507c4c-9a1e-42ef-87a3-7e836d3d38b1_1656721706.7064276.jpeg)\n
['C', 'Sorting', 'C++']