Java || Array + Sorting || beats 99.59% || 12ms || T.C - O(nlogn) S.C - O(1)
\n    // O(nlogn) O(1)\n\tpublic int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {\n\n\t\tArrays.sort(horizontalCuts);\n\t\tArrays.sort(vert
\n    // O(nlogn) O(1)\n\tpublic int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {\n\n\t\tArrays.sort(horizontalCuts);\n\t\tArrays.sort(verticalCuts);\n\n\t\tint loHeight = 0, hiHeight = h, loWidth = 0, hiWidth = w;\n\t\tint hlen = horizontalCuts.length, wlen = verticalCuts.length, mod = 1_000_000_007;\n\t\tlong maxHeight = 0, maxWidth = 0;\n\n\t\tfor (int i = 1; i < hlen; i++) {\n\t\t\tif (horizontalCuts[i] - horizontalCuts[i - 1] > maxHeight)\n\t\t\t\tmaxHeight = horizontalCuts[i] - horizontalCuts[i - 1];\n\t\t}\n\n\t\tif (horizontalCuts[0] - loHeight > maxHeight)\n\t\t\tmaxHeight = horizontalCuts[0] - loHeight;\n\n\t\tif (hiHeight - horizontalCuts[hlen - 1] > maxHeight)\n\t\t\tmaxHeight = hiHeight - horizontalCuts[hlen - 1];\n\n\t\tfor (int i = 1; i < wlen; i++) {\n\t\t\tif (verticalCuts[i] - verticalCuts[i - 1] > maxWidth)\n\t\t\t\tmaxWidth = verticalCuts[i] - verticalCuts[i - 1];\n\t\t}\n\n\t\tif (verticalCuts[0] - loWidth > maxWidth)\n\t\t\tmaxWidth = verticalCuts[0] - loWidth;\n\n\t\tif (hiWidth - verticalCuts[wlen - 1] > maxWidth)\n\t\t\tmaxWidth = hiWidth - verticalCuts[wlen - 1];\n\n\t\treturn (int) ((maxHeight * maxWidth) % mod);\n\t}
[]