C++✅✅ | 2 Heaps🆗 | Self Explanatory Approach | Clean Code |
\n\n# Code\n# PLEASE DO UPVOTE!!!!!\nCONNECT WITH ME ON LINKEDIN -> https://www.linkedin.com/in/md-kamran-55b98521a/\n\n\n\nclass Solution {\npublic:\n\n    int
\n\n# Code\n# PLEASE DO UPVOTE!!!!!\n**CONNECT WITH ME ON LINKEDIN -> https://www.linkedin.com/in/md-kamran-55b98521a/**\n\n```\n\nclass Solution {\npublic:\n\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n        \n        priority_queue<pair<int,int>>mxh;\n        priority_queue<pair<int,int> ,vector<pair<int,int>>, greater<pair<int,int>>>mnh;\n\n        for(int i=0;i<capital.size();++i)\n            mnh.push({capital[i], profits[i]});   \n    \n        while(k > 0)\n        {\n           while(!mnh.empty() && mnh.top().first<=w)\n           {\n               auto p = mnh.top();\n               mnh.pop();\n               mxh.push({p.second, p.first});\n           }\n           if(!mxh.empty())\n           {\n               w += mxh.top().first;\n               mxh.pop();\n               k--;\n           }\n           else break;  \n        }\n\n        return w;\n\n    }\n};\n\n\n```\n![b62ab1be-232a-438f-9524-7d8ca4dbd5fe_1675328166.1161866.png](https://assets.leetcode.com/users/images/7f9b7e51-bb83-477b-8f46-206914549b29_1677132524.1020908.png)\n
['C++']