Understanding the overflow case
Read this: https://medium.com/@pankajjhawar_58850/java-type-casting-and-overflows-22e9065af53d\nAnd then you will understand the solution better: \n\n\nclass So
Read this: https://medium.com/@pankajjhawar_58850/java-type-casting-and-overflows-22e9065af53d\nAnd then you will understand the solution better: \n\n```\nclass Solution {\n    public int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {\n        Arrays.sort(horizontalCuts);\n        Arrays.sort(verticalCuts);\n        int max1 = Math.max(horizontalCuts[0] - 0, h - horizontalCuts[horizontalCuts.length - 1]);\n        for (int i = 1; i < horizontalCuts.length; i++) {\n            max1 = Math.max(max1, horizontalCuts[i] - horizontalCuts[i - 1]);\n        }\n        int max2 = Math.max(verticalCuts[0] - 0, w - verticalCuts[verticalCuts.length - 1]);\n        for (int i = 1; i < verticalCuts.length; i++) {\n            max2 = Math.max(max2, verticalCuts[i] - verticalCuts[i - 1]);\n        }\n        long ans = 1L * max1 * max2;\n        return (int) (ans % 1000000007);\n    }\n}\n```\n
[]