You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:


	horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, and
	verticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.


Return the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. Since the answer can be a large number, return this modulo 109 + 7.

&nbsp;
Example 1:

Input: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]
Output: 4 
Explanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.


Example 2:

Input: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]
Output: 6
Explanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.


Example 3:

Input: h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]
Output: 9


&nbsp;
Constraints:


	2 &lt;= h, w &lt;= 109
	1 &lt;= horizontalCuts.length &lt;= min(h - 1, 105)
	1 &lt;= verticalCuts.length &lt;= min(w - 1, 105)
	1 &lt;= horizontalCuts[i] &lt; h
	1 &lt;= verticalCuts[i] &lt; w
	All the elements in horizontalCuts are distinct.
	All the elements in verticalCuts are distinct.


class Solution:
    def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
        horizontalCuts.sort()
        verticalCuts.sort()
        
        mxHr = 0
        prev = 0
        for i in horizontalCuts:
            mxHr = max(mxHr, i-prev)
            prev = i
        mxHr = max(mxHr, h-horizontalCuts[-1])
        
        mxVr = 0
        prev = 0
        for i in verticalCuts:
            mxVr = max(mxVr, i-prev)
            prev = i
        mxVr = max(mxVr, w-verticalCuts[-1])
        
        return (mxHr * mxVr) % ((10 ** 9) + 7)
import java.math.BigInteger;
class Solution {
    public int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {
        Arrays.sort(horizontalCuts);
        Arrays.sort(verticalCuts);
        int i;
        int hMax=horizontalCuts[0];
        for(i=1;i<horizontalCuts.length;i++)
            // if(hMax < horizontalCuts[i]-horizontalCuts[i-1])
                hMax=Math.max(hMax,horizontalCuts[i]-horizontalCuts[i-1]);
        if(h-horizontalCuts[horizontalCuts.length-1] > hMax)
            hMax= h-horizontalCuts[horizontalCuts.length-1];
        int vMax=verticalCuts[0];
        for(i=1;i<verticalCuts.length;i++)
            // if(vMax < verticalCuts[i]-verticalCuts[i-1])
                vMax=Math.max(vMax,verticalCuts[i]-verticalCuts[i-1]);
        if(w-verticalCuts[verticalCuts.length-1] > vMax)
            vMax= w-verticalCuts[verticalCuts.length-1];
        return (int)((long)hMax*vMax%1000000007);
    }
}
class Solution {
public:
    int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {
        int mod = 1e9 + 7;
        sort(horizontalCuts.begin(), horizontalCuts.end());
        sort(verticalCuts.begin(), verticalCuts.end());
        // cout << 1;
        horizontalCuts.push_back(h);
        verticalCuts.push_back(w);
        // cout << 1;
        int prev = 0;
        int vert = INT_MIN, hori = INT_MIN;
        for(int i = 0; i < verticalCuts.size(); i++)
        {
            if(vert < verticalCuts[i]-prev)
                vert = verticalCuts[i]-prev;
            prev = verticalCuts[i];
        }
        //cout << 1;
        prev = 0;
        for(int i = 0; i < horizontalCuts.size(); i++)
        {
            if(hori < horizontalCuts[i]-prev)
                hori = horizontalCuts[i]-prev;
            prev = horizontalCuts[i];
        }
        return ((long long)vert*hori) % mod;
    }
};
var maxArea = function(h, w, horizontalCuts, verticalCuts) {
    horizontalCuts.sort((a,b) => a-b)
    verticalCuts.sort((a,b) => a-b)
    let max_hor_dis = Math.max(horizontalCuts[0], h - horizontalCuts[horizontalCuts.length-1])
    let max_ver_dis = Math.max(verticalCuts[0], w - verticalCuts[verticalCuts.length-1])
    for(let i=1; i<horizontalCuts.length; i++){
        max_hor_dis = Math.max(max_hor_dis, horizontalCuts[i] - horizontalCuts[i-1])
    }
    for(let i=1; i<verticalCuts.length; i++){
        max_ver_dis = Math.max(max_ver_dis, verticalCuts[i] - verticalCuts[i-1])
    }
    return BigInt(max_hor_dis) * BigInt(max_ver_dis) % BigInt(1e9+7)
};
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts