C++ Priority Queue Efficient Explained Solution
First we will store all the projects in projects vector as pairs {Profit(i), Capital(i)};\n2. Now we will sort all the projects according to its capital value.\
1. First we will store all the projects in projects vector as pairs {Profit(i), Capital(i)};\n2. Now we will sort all the projects according to its capital value.\n3. Now we will fetch all the projects that we can perform for our own capital value. \n4. After fetching all these projects sotre their profit value in Max Heap (maxProfit in below code).\n5. Now check if the Heap is Empty or not, if its not empty then take the top value of the heap (indicates that we chose max profit value from given projects, think greedy here).\n6. Now perform step 3, k times because we want to perform exactly k projects to gain max profit.\n\nclass Solution {\npublic:\n\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        for(int i=0;i<n;i++) projects[i]={profits[i],capital[i]}; \n        int i=0;\n        sort(projects.begin(),projects.end(),[&](pair<int,int> a,pair<int,int> b){ return a.second<b.second;});\n        priority_queue<int> maxProfit;\n        while(k--){\n            while(i<n && w>=projects[i].second) maxProfit.push(projects[i++].first);\n            \n            if(!maxProfit.empty()) w+=maxProfit.top(),maxProfit.pop();\n        }\n        return w;\n    }\n};\n\nHope you understood this, Please UPVOTE : )
['Greedy', 'C', 'Heap (Priority Queue)']