Extremely Simple Using Priority Queue
Sort the class Work in ascending order of difficulty. If difficulty is the same, sort according to descending order of profit. Sort the worker as per ascending 
Sort the class Work in ascending order of difficulty. If difficulty is the same, sort according to descending order of profit. Sort the worker as per ascending order of their ability. \n\nNow you just need to match the work with the worker and store the max profit seen until now and add it to the total profit. \n\n```\npublic class Solution {\n    class Work{\n        int d; \n        int p; \n        Work(int d, int p){\n            this.d = d; \n            this.p = p; \n        }\n    }\n    public int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) {\n        PriorityQueue<Work> pq = new PriorityQueue<Work>((a, b)->(a.d==b.d)?b.p-a.p:a.d-b.d);\n        for(int i = 0; i < profit.length; ++i){\n            pq.offer(new Work(difficulty[i], profit[i])); \n        }\n        Arrays.sort(worker); \n        int i = 0; \n        int cprofit = 0; \n        int max = 0; \n        while(!pq.isEmpty() && i < worker.length){\n            Work w = pq.poll(); \n            if(w.d <= worker[i]){\n                max = Math.max(max, w.p); \n            }else{\n                i++; \n                cprofit+=max; \n                pq.offer(w); \n            }\n        }\n        while(i < worker.length){\n            cprofit+=max; \n            i++; \n        }\n        return cprofit; \n    }\n}\n```
[]