Python sort based
The idea is to sort the profits and difficulty,  based on difficulty.\nAlso the profits array can be modified to store the max_profits till that index.\n\nAfter
The idea is to sort the profits and difficulty,  based on difficulty.\nAlso the profits array can be modified to store the max_profits till that index.\n\nAfter that, its just a matter of finding the correct position for each worker in the difficulty array and adding the max_profit from the profit array.\n\n```\n    def maxProfitAssignment(self, difficulty, profit, worker):\n        difficulty, profit = zip(*sorted(zip(difficulty, profit)))\n        max_profit = -math.inf\n        profit = list(profit)\n        for i in range(len(profit)):\n            if max_profit < profit[i]:\n                max_profit = profit[i]\n            else:\n                profit[i] = max_profit\n        res = 0\n        for w in worker:\n            i = bisect_right(difficulty, w)\n            if i != 0: res += profit[i-1]\n        return res\n```
[]