Heap (Priority Queue)
Intuition & Approach\nhttps://youtu.be/IjddNQDZxWQ\n\n# Code\n\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vect
# Intuition & Approach\nhttps://youtu.be/IjddNQDZxWQ\n\n# Code\n```\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n        int n = profits.size();\n        vector<pair<int, int>> projects(n);\n\n        for (int i = 0; i < n; ++i)\n            projects[i] = {capital[i], profits[i]};\n        \n        sort(projects.rbegin(), projects.rend());\n\n        priority_queue<int> maxProfit;\n        while (k--) {\n            while (!projects.empty() && projects.back().first <= w) {\n                maxProfit.push(projects.back().second);\n                projects.pop_back();\n            }\n\n            if (maxProfit.empty())\n                break;\n            \n            w += maxProfit.top();\n            maxProfit.pop();\n        }\n\n        return w;\n    }\n};\n```
['Greedy', 'Sorting', 'Heap (Priority Queue)', 'C++']