id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) \n {\n vector<pair<int,int>>store;\n int n = capital.size();\n for(int i=0;i<n;i++)\n store.push_back({capital[i], i});\n sort(store.begin(), store.end...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n vector<int>& capital) {\n int n = profits.size();\n std::vector<std::pair<int, int>> projects;\n\n // Creating vector of pairs (capital, profits)\n for (int ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "struct cmp {\n bool operator()(const pair<int, int> &p1, const pair<int, int> &p2) const {\n if (p1.first > p2.first) {\n return true;\n } else if (p1.first == p2.first) {\n return p1.second < p2.second;\n } else {\n return false;\n }\n }\n...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& a, vector<int>& b) {\n int n = (int) a.size();\n vector<int> id(n);\n int ans = w;\n vector<pair<int, int>> p;\n transform(b.begin(), b.end(), a.begin(), back_inserter(p), [] (int x, int y) {\n return make_...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "class Solution {\npublic:\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n=profits.size();\n vector<int> dp(n+1,-1);\n vector<pair<int,int>> v;\n for(int i=0;i<n;i++)\n v.push_back({capital[i],profits[i]});\n /...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "bool comp(pair<int,int> a, pair<int,int> b)\n{\n return a.first < b.first;\n}\n\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital)\n { \n int n = profits.size(), currentCapital = w;\n vector<pair<int,int>> v;\n vec...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "struct T {\n int pro;\n int cap;\n T(int pro, int cap) : pro(pro), cap(cap) {}\n};\n\nclass Solution {\n public:\n int findMaximizedCapital(int k, int W, vector<int>& Profits,\n vector<int>& Capital) {\n auto compareC = [](const T& a, const T& b) { return a.cap > b.cap; };\...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
0
{ "code": "struct T {\n int pro;\n int cap;\n T(int pro, int cap) : pro(pro), cap(cap) {}\n};\n\nclass Solution {\n public:\n int findMaximizedCapital(int k, int W, vector<int>& Profits,\n vector<int>& Capital) {\n auto compareC = [](const T& a, const T& b) { return a.cap > b.cap; };\...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n #define pll pair<int,int>\n\n int findMaximizedCapital(int k, int w, vector<int>& p, vector<int>& c) {\n int actual = w;\n priority_queue<pll> pq;\n\n auto c1 = c;\n sort(c1.begin(),c1.end());\n vector<pll> a;\n for(int i=0;i<p.siz...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct project{\n int profit;\n int capital;\n int visited;\n project(int a, int b):profit(a), capital(b), visited(false){}\n};\n\nbool cmp(project a, project b){\n return a.capital < b.capital;\n}\n\nclass Solution {\n\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profit...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct project{\n int profit;\n int capital;\n int visited;\n project(int a, int b):profit(a), capital(b), visited(false){}\n};\n\nbool cmp(project a, project b){\n return a.capital < b.capital;\n}\n\nclass Solution {\n\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profit...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Project\n{\n Project(): index(0), profit(0), capital(0) \n {\n\n }\n\n Project(int index, int profit, int capital):\n index(index), profit(profit), capital(capital)\n {\n\n }\n\n int index;\n int profit;\n int capital;\n};\n\n// Construct max heap based on profit\nstruc...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Project\n{\n Project(): index(0), profit(0), capital(0) \n {\n\n }\n\n Project(int index, int profit, int capital):\n index(index), profit(profit), capital(capital)\n {\n\n }\n\n int index;\n int profit;\n int capital;\n};\n\n// Construct max heap based on profit\nstruc...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Projects{\n public:\n int profit; \n int capital;\n Projects(int p , int c){\n profit = p ; \n capital = c;\n\n }\n};\nclass compareProfits{\n public:\n bool operator()(Projects a , Projects b){\n return a.profit < b.profit;\n }\n};\nclass compareCapital...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class 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>> pc(n);\n for (int i = 0; i < n; i++) {\n pc[i] = {capital[i], profits[i]};\n }\n // now at ever...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, const vector<int>& profits, const vector<int>& capital)\n {\n std::list<int> l(profits.size());\n std::iota(l.begin(), l.end(), 0);\n\n l.sort(\n [&capital](const int& a, const int& b) {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int profit = w;\n priority_queue<int> doableProfits;\n list<int> nondoableidx;\n //first, place all indexes into a list\n for (int i = 0; i < profits.size...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "#include <iostream>\n#include <algorithm>\n#include <vector>\n#include <queue>\n\nstruct ceva{\nint prof, cap;\n};\n\nvector<ceva> v;\npriority_queue<int> H;\n\nbool cmp(ceva x, ceva y){\n return x.cap < y.cap;\n}\n\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& prof...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "typedef pair<int, int> pii;\n#define F first\n#define S second\n\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n vector<pii> v;\n for (int i = 0; i < n; i++) {\n v.push_back({cap...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution{\npublic:int findMaximizedCapital(int k,int w,vector<int>&profits,vector<int>&capital){\nvector<long long>cp;for(int i=0;i<profits.size();++i)\ncp.push_back(capital[i]*1ll*(int)1e9+(int)1e9-1-profits[i]);sort(cp.begin(),cp.end());int J=0;multiset<int>S;\ndo{while(J<profits.size()&&cp[J]/(int...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n vector<vector<int>> problems(n, vector<int>(2, 0));\n for (int i = 0; i < n; i++) {\n problems[i][0] = capital[i];\n pro...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& p, vector<int>& c) {\n vector<vector<int>> arr(p.size(),vector<int>(2,0));\n for(int i=0;i<p.size();i++){\n arr[i][0]=c[i];arr[i][1]=p[i];\n }\n sort(arr.begin(),arr.end());\n in...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n vector<int> idx(n);\n iota(idx.begin(), idx.end(), 0);\n auto cmp = [&](int a, int b) {\n return capital[a] < capital[b];\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n multiset<int> s;\n multiset<pair<int,int>> sleft;\n int n=profits.size();\n for(int i=0;i<n;i++){\n if(capital[i]<=w){\n s.insert(profi...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n vector<int>& capital) {\n int n = profits.size();\n vector<pair<int, int>> projects(n);\n for (int i = 0; i < n; i++) {\n projects[i].first = capital[i];...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n vector<int>& capital) {\n int n = profits.size();\n vector<pair<int, int>> projects(n);\n for (int i = 0; i < profits.size(); i++) {\n projects[i] = {cap...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class 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>>capital_profit(n);\n for(int i = 0; i < n; i++) {\n capital_profit[i] = {capital[i], profits[i]};\n }\n...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n\n vector<int> idxArr;\n for(int i=0; i<n; i++)\n idxArr.push_back(i);\n\n sort(idxArr.begin(), idxArr.end(), [&](int idx1, i...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n\n vector<int> idxArr;\n for(int i=0; i<n; i++)\n idxArr.push_back(i);\n\n sort(idxArr.begin(), idxArr.end(), [&](int idx1, i...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "typedef pair<int, int> Pair;\n\nstruct MoreProfit {\n constexpr bool operator()( const Pair & a, const Pair & b)\n const noexcept\n {\n return a.first < b.first;\n }\n};\n\n\nstruct LessCost {\n constexpr bool operator()( const Pair & a, const Pair & b)\n const noexcept\n {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n int totalProfit = w;\n set<int> st;\n for(int i=0; i<n; i++) st.insert(i);\n priority_queue<pair<int,int>> pq;\n\n while(...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\nstruct Arr\n{\n int p;\n int c;\n};\n\nstatic bool compare(Arr& x , Arr&y)\n{\n return x.c < y.c;\n};\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n using tuple = pair<int,int>;\n priority_queue<tuple>pq;\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\nstruct Arr\n{\n int p;\n int c;\n};\n\nstatic bool compare(Arr& x , Arr&y)\n{\n return x.c < y.c;\n};\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n using tuple = pair<int,int>;\n priority_queue<tuple>pq;\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "// class Solution {\n// public:\n// int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n// int n = profits.size();\n\n// vector<int> idxArr;\n// for(int i=0; i<n; i++)\n// idxArr.push_back(i);\n\n// sort(idxArr.begin(), idxAr...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int, int>> vec;\n int n = profits.size();\n for (int i = 0; i < n; i++) {\n vec.push_back(make_pair(capital[i], profits[i]));\n }\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class 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>> vec;\n for(int i=0;i<n;i++){\n vec.push_back({capital[i],profits[i]});\n }\n sort(vec.begin(),vec...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n // Function to maximize capital\n int findMaximizedCapital(int k, int w, std::vector<int>& profits, std::vector<int>& capital) {\n // Max-heap for profits\n std::priority_queue<int> maxProfitHeap;\n // Min-heap for projects by capital required\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<vector<int>> projects;\n vector<int> temp;\n for (int i = 0; i < profits.size() ; i++) {\n temp.push_back(profits[i]);\n temp.push_back(capital[i]);\n p...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<pair<int,int>> maxheap;\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> minheap;\n int n=profits.size();\n for(int i=...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<pair<int,int>> maxheap;\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> minheap;\n int n=profits.size();\n for(int i=...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct T {\n int pro;\n int cap;\n T(int pro, int cap) : pro(pro), cap(cap) {}\n};\n\nclass Solution {\n public:\n int findMaximizedCapital(int k, int W, vector<int>& Profits,\n vector<int>& Capital) {\n auto compareC = [](const T& a, const T& b) { return a.cap > b.cap; };\...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n struct prior\n {\n bool operator()(const pair<int, int>&a, const pair<int, int>&b)\n {\n return a.second<b.second;\n }\n };\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) \n {\n int p_s...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Job {\n\n int capital;\n int profit;\n\n Job(int captialRequired, int profitGained)\n : profit(profitGained), capital(captialRequired)\n {}\n\n};\n\nstruct MinCapital {\n\n bool operator () (const Job& j1, const Job& j2) const {\n return j1.capital > j2.capital;\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\n /*\n sort by capital\n */\n\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capitals) {\n if (k == 0) {\n return w;\n }\n\n std::multimap<int,int> capitalMap;\n for (int i = 0; i < capitals.size()...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n Solution() {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(NULL);\n std::cout.tie(NULL);\n }\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<short> available;\n vector<pair<in...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "vector<pair<int,int> > vp;\npriority_queue<int> pq;\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vp.clear();\n while(!pq.empty()) pq.pop();\n for(int i=0; i<capital.size(); i++){\n vp.push_back({capita...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n struct Project\n {\n int id;\n int profit;\n int capital;\n\n Project(int id, int profit, int capital) : id(id), profit(profit), capital(capital) { }\n\n bool operator==(const Project& rhs) const\n {\n return id == rhs.i...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Compare {\n bool operator()(pair<int, int>& a, pair<int, int>& b) const {\n return a.second < b.second;\n }\n};\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n pair<int, int> p...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Compare {\n bool operator()(pair<int, int>& a, pair<int, int>& b) const {\n return a.second < b.second;\n }\n};\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n pair<int, int> p...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "struct Compare {\n bool operator()(pair<int, int>& a, pair<int, int>& b) const {\n return a.second < b.second;\n }\n};\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n pair<int, int> p...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n\n const int n = profits.size();\n pair<int, int> sorted_order[n];\n\n for (int i = 0; i < n; ++i) sorted_order[i] = { capital[i], profits[i] };\n sort(sorted_ord...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "auto untieCin = []() {\n std::cin.tie(0);\n ios_base::sync_with_stdio(false);\n return 0;\n};\n\n// Call the lambda before main using a static variable\nstatic int _ = untieCin();\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "auto untieCin = []() {\n std::cin.tie(0);\n ios_base::sync_with_stdio(false);\n return 0;\n};\n\n// Call the lambda before main using a static variable\nstatic int _ = untieCin();\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n vector<int>& capital) {\n const auto n = profits.size();\n\n const auto ids_sorted = invoke([&] {\n vector<int> ids(n);\n iota(ids.begin(), ids.end()...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<int> order(profits.size());\n iota(order.begin(), order.end(), 0);\n\n sort(order.begin(), order.end(), [&capital](int i, int j) {return capital[i] < capital[j];...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "#define pii pair<int,int>\n#define f first\n#define s second\n#define vpii vector<pii>\nclass Solution {\npublic:\n static bool cmp(pii a, pii b){\n if (a.s<b.s)return true;\n if (a.s>b.s)return false;\n return (a.f>=b.f);\n }\n \n int findMaximizedCapital(int k, int w, vec...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "const int ZERO = []()\n{\nstd::ios_base::sync_with_stdio(false);\nstd::cin.tie(nullptr);\nreturn 0;\n}();\nclass Solution {\n unordered_set<int> used;\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits,\n vector<int>& capital) {\n int n = profits...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n std::ios_base::sync_with_stdio(false);\n\t std::cin.tie(nullptr); \n int n = profits.size(), i=0;\n vector<pair<int, int> >pc(n);\n for(int i=0;i<n;i++...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n ios_base::sync_with_stdio(false);\n \n //Step-1: Sort the projects in increasing order of their capital.\n int n = profits.size();\n vector<pair<int,int>>...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class 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>> v(n);\n for(int i = 0; i<n; i++) {\n v[i] = {capital[i], profits[i]};\n }\n\n sort(v.begin(), ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
1
{ "code": "class 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>> v;\n v.reserve(n);\n\n for (int i = 0; i < n; ++i) {\n v.push_back({capital[i], -profits[i]});\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic: \n struct com\n {\n bool operator()(pair<int,int> a,pair<int,int> b)\n {\n return a.second>b.second;\n }\n };\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<int> q;\n\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n //int * orders = (int*)malloc(n*sizeof(int));\n //for(int i = 0;i<n;i++) orders[i]=i;\n\n //std::sort(orders, orders + n, [&capital](...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int,int>> v;\n int i;\n for (i=0;i<profits.size();i=i+1)\n {\n v.push_back(make_pair(profits[i],capital[i]));\n }\n sort(v.b...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n vector<int> index_arr(n);\n for(int i = 0;i<n;i++){\n index_arr[i] = i;\n }\n sort(index_arr.begin(), index_arr.end()...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profit, vector<int>& capital) {\n vector<pair<int,int>> v1;\n for( int i=0; i< profit.size(); i++) v1.push_back({ capital[i], profit[i]});\n sort(v1.begin(), v1.end());\n int a=0;\n map<int...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n // no point trying higher capital for less profit\n std::vector<std::pair<int, int>> mappedCapitals;\n for (int i = 0; i < profits.size(); i++)\n {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int> &profits,\n vector<int> &capital) {\n long n = profits.size();\n int maxCapital = w;\n vector<pair<int, long>> capitalVec;\n priority_queue<int, vector<int>, std::less<>> pq;\n\n capital...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int i = 0;\n int count = 0;\n\n vector<pair<int, int>> v;\n for (int i = 0; i < profits.size(); i++) {\n v.push_back({capital[i], profits[i]});\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "struct Project \n{\n int capital;\n int profit;\n};\n\nstruct CompareProfit \n{\n bool operator()(const Project& a, const Project& b) \n {\n return a.profit < b.profit; \n }\n};\nclass Solution \n{\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>&...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "struct Project {\n int profit;\n int capital;\n\n bool operator< (const Project& b) const {\n return this->profit < b.profit;\n }\n};\n\nclass Solution {\n int lastLEQ(const vector<Project>& projects, int cap) {\n const int len = projects.size();\n int l = 0, r = len - 1...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
2
{ "code": "struct Compare {\n bool operator()(const pair<int, int> &a, const pair<int,int> &b) {\n return a.first < b.first;\n }\n};\n\nstruct Compare2 {\n bool operator()(const pair<int, int> &a, const pair<int,int> &b) {\n return a.first > b.first;\n }\n};\n\nclass Solution {\npublic:\n int findMaximiz...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n deque<project> projects;\n for (int i = 0; i < profits.size(); i ++) {\n projects.push_back({profits[i],capital[i]});\n }\n \n sort (projects.b...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n deque<project> projects;\n for (int i = 0; i < profits.size(); i ++) {\n projects.push_back({profits[i],capital[i]});\n }\n \n sort (projects.b...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<vector<int>> capx;\n priority_queue<vector<int>> gain;\n int n = profits.size();\n for (int i=0; i<n; i++){\n capx.push_back({capital[i],profit...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n // bool way(pair<int,int>a,int cap){\n // return a.first < cap;\n // }\n // int binarysearch(int cap, vector<pair<int,int>> &cp,int start,int end){\n // // int n=cp.size();\n // // int mid = (start+end)/2;\n // // if(end-start)\n // //...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "\nstruct project{\n int capital;\n int profit;\n};\n\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n \n ios_base::sync_with_stdio(0);\n \n int n = profits.size();\n vector<project> projects;\n fo...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "#define PII pair<int, int>\nclass Solution {\n struct capitalCompare\n {\n bool operator () ( const PII &a, const PII &b)\n {\n return b.first < a.first;\n }\n };\n struct profitCompare\n {\n bool operator() (const PII &a, const PII &b)\n {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n struct CustomSort {\n bool operator()(auto a, auto b){\n return a.first < b.first;\n };\n };\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int,int>> projects;\n\n for(int i = 0...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "#define PII pair<int, int>\nclass Solution {\n struct capitalCompare\n {\n bool operator () ( const PII &a, const PII &b)\n {\n return b.first < a.first;\n }\n };\n struct profitCompare\n {\n bool operator() (const PII &a, const PII &b)\n {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "typedef pair<int, int> entry;\nclass Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<entry> decision;\n for(int index = 0; index < profits.size(); index++) {\n decision.push_back({capital[index], profits[index]}...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\n \n class SatCompare {\n public:\n bool operator()(tuple<int, int, int> a, tuple<int, int, int> b){\n return get<0>(a) < get<0>(b);\n }\n };\n\n class UnsatCompare {\n public:\n bool operator()(tuple<int, int, int> a, tuple<int...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n map<int, vector<int>> levels;\n vector<int> elements;\n for (size_t i = 0; i < capital.size(); ++i) {\n levels[capital[i]].push_back(profits[i]);\n }\...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int,int>> capProfMap(profits.size());\n for(int i=0; i<profits.size(); i++) {\n capProfMap.push_back({capital[i], profits[i]});\n }\n sort...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int,int>> capProfMap(profits.size());\n for(int i=0; i<profits.size(); i++) {\n capProfMap.push_back({capital[i], profits[i]});\n }\n sort...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n vector<pair<int,int>> capProfMap(profits.size());\n for(int i=0; i<profits.size(); i++) {\n capProfMap.push_back({capital[i], profits[i]});\n }\n sort...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int W, vector<int>& P, vector<int>& C) {\n priority_queue<int> low; // P[i]'s within current W\n multiset<pair<int,int>> high; // (C[i],P[i])'s' outside current W\n \n for (int i = 0; i < P.size(); ++i) // initialize lo...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<int>can_take;\n set<pair<int,int>>remaining;\n int n = profits.size();\n for(int i = 0; i<n ; ++i){\n if(w < capital[i]) {\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n struct comp {\n bool operator()(const pair<int,int> &p1, const pair<int,int> &p2) {\n return p1.first>p2.first;\n }\n };\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n int n = profits.size();\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n multiset<int> canprofits2 = {};\n vector<int> profits2 = {};\n multiset<int> capital2 = {};\n vector<vector<int>> stuffs = {};\n int n = profits.size();\n...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\n typedef long long ll;\npublic:\n int findMaximizedCapital(int k, long long w, vector<int>& profits, vector<int>& capital) {\n vector<pair<ll,int>>vect;\n int n=profits.size();\n for(int i=0;i<n;i++){\n vect.push_back({capital[i],profits[i]});\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\n typedef long long ll;\npublic:\n int findMaximizedCapital(int k, long long w, vector<int>& profits, vector<int>& capital) {\n vector<pair<ll,int>>vect;\n int n=profits.size();\n for(int i=0;i<n;i++){\n vect.push_back({capital[i],profits[i]});\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n typedef pair<int,int>p;\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<int>pq1;\n priority_queue<p,vector<p>,greater<p>>pq2;\n int n=profits.size();\n vector<pair<int,int>>store;\n ...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n\n void bubbleUp(vector<pair<int,int>>& values, int index) {\n while(index > 1)\n {\n if(values[index / 2].second < values[index].second)\n {\n swap(values[index / 2], values[index]);\n } else {\n bre...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n priority_queue<int> prof;\n priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> cap;\n for (int i = 0; i < profits.size(); i++) cap.push({capital[i],...
502
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
3
{ "code": "#define ll long long\n\nclass Solution {\npublic:\n\n vector< pair<long long, long long> > vv;\n\n pair<ll,int> tree[400005];\n\n void update(int node, int b, int e, int id, ll x) {\n if(id<b || id>e) return;\n if(id == b && id == e) {\n tree[node].first = x;\n ...
438
<p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>&#39;s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p> <p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d...
0
{ "code": "\nclass Solution {\npublic:\n Solution() {\n ios_base ::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n // Anuj Bontalwar\n bool asb(vector<int> &a) {\n for(int i=0;i<a.size();i++) {\n if(a[i]!=0) {\n return false;\n ...
438
<p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>&#39;s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p> <p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d...
0
{ "code": "\nclass Solution {\npublic:\n Solution() {\n ios_base ::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n // Anuj Bontalwar\n bool asb(vector<int> &a) {\n for(int i=0;i<a.size();i++) {\n if(a[i]!=0) {\n return false;\n ...
438
<p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>&#39;s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p> <p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d...
2
{ "code": "class Solution {\npublic:\n vector<int> findAnagrams(string s, string p) {\n vector<int>mp1(26,0);\n vector<int>mp2(26,0);\n vector<int>result;\n int hash1=0,hash2=0,st=-1,j;\n for(auto x:p)\n {\n \n if(mp1[x-'a']==0)\n hash1=...
438
<p>Given two strings <code>s</code> and <code>p</code>, return <em>an array of all the start indices of </em><code>p</code><em>&#39;s anagrams in </em><code>s</code>. You may return the answer in <strong>any order</strong>.</p> <p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a d...
2
{ "code": "class Solution {\npublic:\nbool static cmp(int arr1[],int arr2[]){\n for(int i=0;i<256;i++){\n if(arr1[i]!=arr2[i]) return false;\n }\n return true;\n}\n vector<int> findAnagrams(string s, string p) {\n int n=s.size();\n int m=p.size();\n int counts[256]={0};\n ...