Easy C++ Solution With Video Explanation
Video Explanation\nhttps://youtu.be/1HMNDlOeoWA?si=A2YEqXQuLpQwmU8s\n\n# Complexity\n- Time complexity:O(nlogn+mlogm)\n Add your time complexity here, e.g. O(n)
# Video Explanation\nhttps://youtu.be/1HMNDlOeoWA?si=A2YEqXQuLpQwmU8s\n\n# Complexity\n- Time complexity:$$O(nlogn+mlogm)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$ \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n\n        int n = difficulty.size();\n        int m = worker.size();\n\n        vector<pair<int,int>> job;\n\n        for(int i=0;i<n;i++){\n\n            job.push_back({difficulty[i], profit[i]});\n            \n        }\n\n        sort(job.begin(),job.end());\n        sort(worker.begin(),worker.end());\n\n        int j = 0;\n        int currProfit = 0;\n        int totalProfit = 0;\n        \n        for(int i=0;i<m;i++){\n\n            while(j<n && worker[i] >= job[j].first){\n\n                currProfit = max(currProfit, job[j].second);\n                j++;\n            }\n\n            totalProfit += currProfit;\n            \n        }\n\n        return totalProfit;\n    }\n};\n```
['C++']