just a variant
Code\nKotlin []\nclass Solution {\n    fun maxProfitAssignment(difficulty: IntArray, profit: IntArray, worker: IntArray): Int {\n        val jobs = profit.foldI
# Code\n``` Kotlin []\nclass Solution {\n    fun maxProfitAssignment(difficulty: IntArray, profit: IntArray, worker: IntArray): Int {\n        val jobs = profit.foldIndexed(mutableListOf<Pair<Int, Int>>()) { i, r, p -> r.add(difficulty[i] to p); r }\n        worker.sort()\n        jobs.sortBy { it.first }\n        var i = 0\n        var best = 0\n        val n = profit.size\n        return worker.sumOf { a ->\n                                    while (i < n && a >= jobs[i].first) best = maxOf(best, jobs[i++].second)\n                                    best \n                }\n    }\n}\n```\n```Rust []\nimpl Solution {\n    pub fn max_profit_assignment(difficulty: Vec<i32>, profit: Vec<i32>, worker: Vec<i32>) -> i32 {\n        let n = profit.len();\n        let mut jobs: Vec<(i32, i32)> = difficulty.into_iter().zip(profit).collect();\n        let mut worker = worker;\n        worker.sort_unstable();\n        jobs.sort_unstable();\n        let mut i = 0usize;\n        let mut best = 0;\n        worker.iter().fold(0, |r, a| {\n                        while i < n && *a >= jobs[i].0 {\n                            best = std::cmp::max(best, jobs[i].1);\n                            i +=1;\n                        }\n                        r + best })\n    }\n}\n```
['Rust', 'Kotlin']