826. Most Profit Assigning Work Easy Greedy Approach :
Intuition\n Describe your first thoughts on how to solve this problem. \nProblem statements deals with maximizing total profit,which indicates greedy approach.\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nProblem statements deals with maximizing total profit,which indicates greedy approach.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1>**Pair Jobs with Profits:**\nCreate a list of pairs where each pair consists of a job\'s difficulty and its corresponding profit.\n\n**2>Sort Jobs and Workers:**\nSort the jobs list by difficulty.\nSort the w list of workers\' abilities.\n\n**3>Maximize Profit:**\nInitialize variables to keep track of the current maximum profit and total profit.\nUse two pointers/indices: one to iterate through the workers and another to iterate through the jobs.\nFor each worker, find the highest-paying job they can do. Update the total profit accordingly.\n\n# Complexity\n- Time complexity: **O(nlogn+mlogm)**\n\n- Space complexity: **O(n)**\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& d, vector<int>& p, vector<int>& w) {\n        vector<pair<int,int>> jobs;\n        int n = d.size();\n        for(int i=0;i<n;i++)\n            jobs.push_back({d[i],p[i]});\n\n        sort(jobs.begin(),jobs.end());\n        long long pr = 0;\n        sort(w.begin(),w.end());\n        int idx = -1;\n        int m = w.size();\n        int val = INT_MIN;\n        for(int i=0;i<m;i++)\n        {\n            while(idx+1<n && jobs[idx+1].first <= w[i])\n            {\n                idx++;\n                val = max(val,jobs[idx].second);\n            }\n            if(val != INT_MIN) pr += val;\n        }\n        return pr;\n    }\n};\n\n//[[35,17] , [47,81] , [52,1] , [68,67] , [86,3]]\n//[ 10    ,   82    ,    84   ,   85    ,   92  ]\n\n//0+67+67+67+3\n\n\n```
['C++']