just taking out the maximum cuts distance in btw
\n\n    class Solution {\n    long m=(long)1e9+7;\n    public int maxArea(int h, int w, int[] horizontal, int[] vertical) {\n        long maxHorizontal=0;\n    
\n\n    class Solution {\n    long m=(long)1e9+7;\n    public int maxArea(int h, int w, int[] horizontal, int[] vertical) {\n        long maxHorizontal=0;\n        long maxVertical=0;\n        Arrays.sort(horizontal);\n        Arrays.sort(vertical);\n        //horizontal condition\n        //if horizontal array length is 1 just checking the maximum boundary distance\n        if(horizontal.length==1){\n            maxHorizontal=Math.max(horizontal[0],(long)h-horizontal[0]);\n        }\n        \n        //otherwise checking the maximum gap between the cuts\n        else{\n            for(int i=1;i<horizontal.length;i++){\n                maxHorizontal=Math.max(maxHorizontal,(horizontal[i]-horizontal[i-1]));\n            }\n            \n            maxHorizontal=Math.max(maxHorizontal,horizontal[0]);\n            maxHorizontal=Math.max(maxHorizontal,(long)h-horizontal[horizontal.length-1]);\n        }\n        \n        //vertical condition\n        //if vertical array length is 1 just checking the maximum boundary distance\n        if(vertical.length==1){\n            maxVertical=Math.max(vertical[0],(long)w-vertical[0]);\n        }\n        \n        //otherwise checking the maximum gap between the cuts\n        else{\n            for(int i=1;i<vertical.length;i++){\n                maxVertical=Math.max(maxVertical,(vertical[i]-vertical[i-1]));\n            }\n            \n            maxVertical=Math.max(maxVertical,vertical[0]);\n            maxVertical=Math.max(maxVertical,(long)w-vertical[vertical.length-1]);\n        }\n        \n    //  returning the max area\n        return (int)((maxVertical*maxHorizontal)%m);\n    }\n}
['Greedy', 'Sorting']