mere jese dimag walo ke liye asaan solution
Intuition\nIs problem mein humein difficulty aur profit arrays diye gaye hain jo kaam ki mushkilat aur uske corresponding munafa ko dikhate hain. Ek worker arra
# Intuition\nIs problem mein humein difficulty aur profit arrays diye gaye hain jo kaam ki mushkilat aur uske corresponding munafa ko dikhate hain. Ek worker array bhi diya gaya hai jo har worker ki maximum mushkilat jo wo handle kar sakta hai ko dikhata hai. Humein yeh batana hai ki workers kitna maximum munafa kama sakte hain.\n\n# Approach\nData Preparation:\nPehle, difficulty aur profit ko ek 2D array difPro mein combine karte hain jismein har sub-array difficulty aur profit ko store karta hai.\n\nSorting:\nworker array ko sort karte hain.\ndifPro array ko difficulty ke basis pe sort karte hain.\n\nPriority Queue:\nEk PriorityQueue banate hain jo max-heap ke tarah kaam karegi, taaki hamesha maximum profit head pe ho.\n\nMain Logic:\nHar worker ke liye, hum unka maximum profit find karte hain jo wo kar sakte hain:\nHar worker ke liye, hum difPro array ko traverse karte hain aur jitne kaam wo worker kar sakta hai unka profit PriorityQueue mein add karte hain.\nAgar PriorityQueue khali nahi hai, to current maximum profit ko answer mein add karte hain.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(m)\n\n# Code\n```\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.PriorityQueue;\n\nclass Solution {\n    public int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) {\n        int n = difficulty.length;\n        int[][] difPro = new int[n][2];\n        for(int i = 0; i < n; i++) {\n            difPro[i][0] = difficulty[i];\n            difPro[i][1] = profit[i];\n        }\n\n        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());\n\n        // Worker array ko sort karte hain\n        Arrays.sort(worker);\n        // difPro array ko difficulty ke basis pe sort karte hain\n        Arrays.sort(difPro, (a, b) -> Integer.compare(a[0], b[0]));\n\n        int m = worker.length;\n        int i = 0;\n        int j = 0;\n        int ans = 0;\n        \n        while (i < m) {\n            // Workers ke liye mushkilat ke hisaab se profit add karte hain\n            while (j < difPro.length && difPro[j][0] <= worker[i]) {\n                pq.offer(difPro[j][1]);\n                j++;\n            }\n            // Agar priority queue empty nahi hai to maximum profit add karte hain\n            if (!pq.isEmpty()) {\n                ans += pq.peek();\n            }\n            i++;\n        }\n        return ans;\n    }\n}\n\n```
['Heap (Priority Queue)', 'Java']