a few solutions
Sort the input arrays A and B (with cardinality M and N correspondingly) to find the product of maximum adjacent differences between cuts.\n\n---\n\nKotlin\n\nc
Sort the input arrays `A` and `B` (with cardinality `M` and `N` correspondingly) to find the product of maximum adjacent differences between cuts.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n    fun maxArea(M: Int, N: Int, A_: IntArray, B_: IntArray): Int {\n        var A = A_.sorted().toMutableList(); A.add(M)\n        var B = B_.sorted().toMutableList(); B.add(N)\n        var f = { A: MutableList<Int> -> A.mapIndexed{ i, _ -> if (0 < i) A[i] - A[i - 1] else A[0] }.max()!!.toLong() }\n        return (f(A) * f(B) % (1e9 + 7).toLong()).toInt()\n    }\n}\n```\n\n*Javascript*\n```\nlet maxArea = (M, N, A, B, cmp = (a, b) => a - b) => {\n    A.sort(cmp), A.push(M);\n    B.sort(cmp), B.push(N);\n    let f = A => BigInt(Math.max(...A.map((_, i) => 0 < i ? A[i] - A[i - 1] : A[0])));\n    return f(A) * f(B) % BigInt(1e9 + 7);\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def maxArea(self, M: int, N: int, A: List[int], B : List[int], best = 0) -> int:\n        A.sort(); A.append(M)\n        B.sort(); B.append(N)\n        f = lambda A: max(A[i] - A[i - 1] if i else A[0] for i in range(len(A)))\n        return f(A) * f(B) % int(1e9 + 7)\n```\n\n*Rust*\n```\ntype VI = Vec<i32>;\nimpl Solution {\n    pub fn max_area(M: i32, N: i32, mut A: VI, mut B: VI) -> i32 {\n        A.sort(); A.push(M);\n        B.sort(); B.push(N);\n        let f = (|A: VI| A.iter().enumerate().map(|(i, _)| if 0 < i { A[i] - A[i - 1] } else { A[0] }).max().unwrap() as i64);\n        (f(A) * f(B) % (1e9 as i64 + 7)) as i32\n    }\n}\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VI = vector<int>;\n    using LL = long long;\n    int maxArea(int M, int N, VI& A, VI& B) {\n        sort(A.begin(), A.end()); A.push_back(M);\n        sort(B.begin(), B.end()); B.push_back(N);\n        auto f = [](auto& A) -> LL {\n            auto best = A[0];\n            for (auto i{ 1 }; i < A.size(); ++i) {\n                auto cand = A[i] - A[i - 1];\n                best = max(best, cand);\n            }\n            return best;\n        };\n        return f(A) * f(B) % int(1e9 + 7);\n    }\n};\n```\n
[]