C++ Easy code beginner level.
IntuitionThe problem involves finding the largest rectangular piece of a cake after making specified horizontal and vertical cuts. To achieve this:Sort Cuts: So
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem involves finding the largest rectangular piece of a cake after making specified horizontal and vertical cuts. To achieve this:

Sort Cuts: Sorting ensures that we calculate gaps between consecutive cuts correctly.
Calculate Maximum Gaps: The largest piece of cake in each dimension (height and width) depends on the maximum gap between consecutive horizontal and vertical cuts.
Multiply the Maximum Gaps: The maximum area of a piece of cake is obtained by multiplying the largest horizontal gap with the largest vertical gap.

# Approach
<!-- Describe your approach to solving the problem. -->
1. **Sort the Cuts:** Sort both horizontalCuts and verticalCuts to find gaps between adjacent cuts.
2. **Add Edge Cuts:** Add the dimensions of the cake (h and w) as the last cuts to include the edges.
3. **Find Maximum Gaps:**
Use a helper function to calculate the maximum gap in each sorted array.
Consider the gap between the first cut and the edge (0) as well.
4. **Calculate Area:** Multiply the maximum horizontal gap and maximum vertical gap, then take modulo 1000000007.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
Sorting: Sorting horizontalCuts and verticalCuts takes `O(nlogn+mlogm)`, where n is the size of horizontalCuts and m is the size of verticalCuts.

Find Gaps: Finding maximum gaps involves traversing the arrays, taking `O(n+m).`
Overall:
`O(nlogn+mlogm)`

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1) //Nothing used.

# Code
```cpp []
class Solution {
public:
    long long findMaxGap(vector<int>arr){
        long long maxG=arr[0];
        for(int i=1;i<arr.size();i++){
            long long g=arr[i]-arr[i-1];
            if(g>maxG){
                maxG=g;
            }
        }
        return maxG;
    }
    int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {
        sort(horizontalCuts.begin(),horizontalCuts.end());
        sort(verticalCuts.begin(),verticalCuts.end());

        horizontalCuts.push_back(h);
        verticalCuts.push_back(w);

        long long maxh=findMaxGap(horizontalCuts);
        long long maxw=findMaxGap(verticalCuts);
        cout<<maxh<<endl;
        cout<<maxw<<endl;

        return (maxh*maxw)%1000000007;
        
    }
};
```
['Sorting', 'C++']