🔥 🔥 🔥 Simple Approch 🔥 🔥 🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to maximize the available capital w after k investment rounds. Each project
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to maximize the available capital w after k investment rounds. Each project has a specific profit and capital requirement. We need to strategically choose projects that can be funded with the current capital and yield the highest profit.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.Min-Heap for Capital Requirements:\n-->Use a min-heap (minHeap) to store projects based on their capital requirements. This allows us to quickly identify projects that can be funded with the current capital.\n\n2.Max-Heap for Profits:\n-->Use a max-heap (maxHeap) to store the profits of the projects that can be funded. This helps in selecting the most profitable project available at any step.\n\n3.Iterative Process:\n-->Initially, push all projects into the minHeap.\n-->For each of the k investment rounds:\n    ----->Transfer all projects from minHeap to maxHeap that can be funded with the current capital w.\n----->If there are no more projects that can be funded (i.e., maxHeap is empty), break the loop.\n----->Otherwise, select the project with the highest profit (top of maxHeap), add its profit to the current capital w, and remove it from maxHeap.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nhe overall time complexity is O(nlogn+klogn).\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nBoth heaps (minHeap and maxHeap) can store up to n elements.\nTherefore, the space complexity is O(n).\n# Code\n```\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> minHeap;\n        priority_queue<int> maxHeap;\n        for (int i = 0; i < profits.size(); i++) {\n            minHeap.push({capital[i], profits[i]});\n        }\n        for (int i = 0; i < k; i++) {\n            while (!minHeap.empty() && minHeap.top().first <= w) {\n                maxHeap.push(minHeap.top().second);\n                minHeap.pop();\n            }\n            if (maxHeap.empty()) break;\n            w += maxHeap.top();\n            maxHeap.pop();\n        }\n        return w;\n    }\n};\n```
['C++']