Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
\n\n//we basically have to find the maximum distance between two consecutive vertical cuts and hhorizontal cuts\nclass Solution {\n    \n    public int maxArea(
![image](https://assets.leetcode.com/users/images/8d98737b-a8d0-4c23-b2c4-4959cfdb983a_1656742481.3865132.jpeg)\n```\n//we basically have to find the maximum distance between two consecutive vertical cuts and hhorizontal cuts\nclass Solution {\n    \n    public int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {\n        //sort both the arrays\n        Arrays.sort(horizontalCuts);\n        Arrays.sort(verticalCuts);\n        //find max diff between two consecutive horizontal cuts\n        int maxh = horizontalCuts[0];\n        for(int i=1;i<horizontalCuts.length;i++)\n            maxh = Math.max(horizontalCuts[i]-horizontalCuts[i-1],maxh);\n        maxh = Math.max(h-horizontalCuts[horizontalCuts.length-1],maxh);\n        //find max diff between two consecutive vertical cuts\n        int maxw = verticalCuts[0];\n        for(int i=1;i<verticalCuts.length;i++)\n            maxw = Math.max(verticalCuts[i]-verticalCuts[i-1],maxw);\n        maxw = Math.max(w-verticalCuts[verticalCuts.length-1],maxw);\n        \n        long ans = 1l*maxh*maxw;\n        return (int)(ans%1000000007);\n    }\n}\n```
['Java']