[Java] Sorting and Two Pointer approach Using HashMap
\nclass Solution {\n    public int maxProfitAssignment(int[] diff, int[] pro, int[] work) {\n        int maxProfit=0;\n        Map<Integer,Integer> map=new Hash
```\nclass Solution {\n    public int maxProfitAssignment(int[] diff, int[] pro, int[] work) {\n        int maxProfit=0;\n        Map<Integer,Integer> map=new HashMap<>(); \n        for(int i=0;i<pro.length;i++){\n            if(map.get(pro[i])!=null && map.get(pro[i])<diff[i]){\n                continue;\n            }\n            map.put(pro[i],diff[i]);\n        }\n        Arrays.sort(pro);\n        Arrays.sort(work);\n        int w=work.length-1;\n        int p=pro.length-1;\n        while(w>=0 && p>=0) {\n            if(map.get(pro[p])<=work[w]){\n                maxProfit+=pro[p];\n                w--;\n            } else{\n                p--;\n            }\n        }\n        return maxProfit;\n    }\n}\n```
['Java']