Much Intuitive ||  Binary Search + Greedy || Simple And Easy TO Understand  || C++ Solution
Intuition\nWe Can Sort The Difficulty - Profit Pair And Use Binary Search For Assigning Jobs TO Workers\n# Approach\nWhy Sorting Based ON Difficulty but Not on 
# Intuition\nWe Can Sort The Difficulty - Profit Pair And Use Binary Search For Assigning Jobs TO Workers\n# Approach\nWhy Sorting Based ON Difficulty but Not on Profit, Because In The Given Problem Workers Difficulty Level  Capability Is Provided Based On these Data We Should Assign The Jobs To Workers.\nNow After Sorting Difficulty And Profit Pair , we Should Observe ONE Important Point Here\nConsider The Example\n Difficulty : [68,35,52,47,86]\n Profit:[67,17,1,81,3]\nWorkers :[92,10,85,84,82]\nIf We Sort Difficulty And Profit Pair We Get \nDifficulty :[35,47,52,68,86]\nProfit : [17,81,1,67,3]\n**Important Observation\nIf A Worker Can Do A Job At difficulty Level X then he can do all Jobs With difficulty level less than or Equal to X**\nNow if X=52 , What is The Maximum Profit ,we Can Get it is 81 .\nAt difficulty level 81 we have maxprofit 81.\nSo we should Update The Profit Values With Maximum Values From Previous Ones \nie; \nat i=1 profit[i]=max(profit[i],profit[i-1])=(81,17)=81\n    at i=2 profit[i]=max(profit[i],profit[i-1])=(1,81)=81\n    at i=3 profit[i]=max(profit[i],profit[i-1])=(67,81)=81\n    at i=4 profit[i]=max(profit[i],profit[i-1])=(3,81)=81\nThe Profit Array Becomes [17,81,81,81,81]\nNow We Can Apply Binary Search (Upper Bound) For Every Worker Individually And Assign Jobs Finally Get The Max Profit.\n\n**PLEASE UPVOTE IF UNDERSTAND THE SOLUTION**\n\n\n# Complexity\n- Time complexity:\nO(NLOGN+MLOGN)\n- Space complexity:\n# Code\n```\nclass Solution {\npublic:\n    int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n        vector<pair<int,int>>arr;\n         int n=difficulty.size();\n     \n         for(int i=0;i<n;i++)\n         {\n             arr.push_back({difficulty[i],profit[i]});\n         }       \n           sort(arr.begin(),arr.end());\n\n             for(int i=1;i<n;i++) arr[i].second=max(arr[i].second,arr[i-1].second);\n         long long maxprofit=0;\n         int low,high,mid,temprofit;\n         for(auto i:worker)\n         {\n             low=0,high=n-1,temprofit=0;\n             while(low<=high)\n             {\n                 mid=(low+high)/2;\n                 if(arr[mid].first<=i)        low=mid+1;\n                 else high=mid-1;\n             }\n          if(high>=0)   maxprofit=(long long)maxprofit+arr[high].second;\n         }\n         return maxprofit;\n    }\n};\n```
['Binary Search', 'Greedy', 'C++']