~Beginner Friendly C++ Solution Using Map || ~Easy Approach || O(Nlogn)
Do Upvote if you find it Helpful \u2764\uFE0F\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nSince it is a greedy problem we can 
>*Do Upvote if you find it Helpful* \u2764\uFE0F\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince it is a greedy problem we can easily solve it through sorting.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- First we map the Maximum profit available for each difficult in a map named `mp`, this is done for fast and easy retrieval of profits for any said difficulty.\n\n- Then we sort the `Worker` and the `difficulty` vectors.\n\n- Now, we begin iterating through the `worker` vector till we encounter a difficulty that is more than the worker can withstand.\n\n- We store the max profit the current worker can obtain in a variable named `cp`. We use `cp` to keep track of the maximum profit encountered so far as it iterates through the sorted difficulties.\n\n- This is because for each worker, we want to find the maximum profit job they can handle up to their skill level\n\n- At last, we accumulate the total profit that can be achieved by all workers in the `ans` variable,\n\n\n\n# Complexity\n- Time complexity: $$O(Nlogn+Wlogw)$$\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        int w = worker.size();\n        int n = profit.size();\n\n        map<int,int> mp;\n\n        for(int i=0;i<n;i++){\n            mp[difficulty[i]] = max(profit[i],mp[difficulty[i]]);\n        }\n\n        sort(difficulty.begin(),difficulty.end());\n        sort(worker.begin(),worker.end());\n\n        int ans = 0;\n        int j = 0;\n        int cp = 0;\n\n        for(int i=0;i<w;i++){\n            while(j<n && worker[i] >= difficulty[j]){\n                cp = max(cp,mp[difficulty[j]]);\n                j++;\n            }\n                ans+=cp;\n        }\n\n    return ans;\n\n\n    }\n};\n```
['Array', 'Hash Table', 'Greedy', 'Sorting', 'C++']