id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int> &plantTime, vector<int> &growTime) {\n vector<int> id(plantTime.size());\n iota(id.begin(), id.end(), 0);\n sort(id.begin(), id.end(), [&](int i, int j) { return growTime[i] > growTime[j]; });\n int ans = 0, day = ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n vector<int> idx(n);\n iota(idx.begin(), idx.end(), 0);\n sort(idx.begin(), idx.end(), [&](int i, int j) { return growTime[j] < growTime[i]; });\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size(), sum = 0, ans = 0;\n vector<int> a(n);\n iota(a.begin(), a.end(), 0);\n sort(a.begin(), a.end(), [&] (int& a, int& b) {\n return growTime[a... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n\n vector<int> index(n);\n for (int i = 0; i < n; ++i) {\n index[i] = i;\n }\n\n sort(index.begin(), index.end(), [&growTime](int ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n std::vector<int> order(plantTime.size());\n std::ranges::iota(order, 0);\n std::ranges::sort(order,[&](int const lhs, int const rhs) { return growTime[lhs] > growTime[rhs]; });\n\n in... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n // pt => plantTime and gt ==> growntime;\n int earliestFullBloom(vector<int>& pt, vector<int>& gt) {\n int n = pt.size();\n vector<int>idx(n);\n iota(idx.begin(), idx.end(), 0);\n sort(idx.begin(), idx.end(), [&](int a, int b){\n if(g... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int grow {};\n int plant {};\n\n vector<int> flowers (plantTime.size());\n std::iota(flowers.begin(), flowers.end(), 0);\n ranges::sort(flowers,\n [&growTime... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\nbool static comp(pair<int,int> p1,pair<int,int>p2){\n return p1.second>p2.second;\n}\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n=plantTime.size();\n vector<pair<int,int>> ans(n);\n for(int i=0;i<n;i++){\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n static bool comp(const pair<int,int>a,const pair<int,int>b){\n return a.second>b.second;\n }\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> v(growTime.size());\n if(growTime.size()==1){\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "#define pii pair<int,int>\nclass Solution {\npublic:\n int earliestFullBloom(vector<int>& p, vector<int>& g) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n\n int n=p.size();\n vector<pii> v(n);\n \n for(int i=0; i<n; i++){\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n int n=plantTime.size();\n vector<pair<int,int>> v(n);\n for(int i=0;i<n;i++)\n v[i]={plantTi... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n ios::sync_with_stdio(false);\n int n=plantTime.size();\n vector<pair<int, int>> vec(n);\n for (int i = 0; i < n; i++) {\n vec[i] = {plantTime[i], growTime[i]};\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n // growTime larger first\n vector<pair<int, int>> times(n);\n for (int i = 0; i < n; i++) {\n times[i].first = -growTime[i];\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 0 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n vector<pair<int,int>> vec(n);\n for(int i = 0; i<n; i++) vec[i] = {plantTime[i], growTime[i]};\n \n auto lambda = [](pair<int, int>& P1, pa... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& a, vector<int>& b) {\n ios_base::sync_with_stdio(0);\n cin.tie(NULL);\n // cout.tie(NULL);\n int n = a.size();\n vector<pair<int,int>> temp(n);\n for(int i = 0;i<n;i++){\n temp[i] = {b[i]... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& a, vector<int>& b) {\n ios_base::sync_with_stdio(0);\n // cin.tie(NULL);\n // cout.tie(NULL);\n int n = a.size();\n vector<pair<int,int>> temp(n);\n for(int i = 0;i<n;i++){\n temp[i] = {b... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& a, vector<int>& b) {\n ios_base::sync_with_stdio(0);\n cin.tie(NULL);\n cout.tie(NULL);\n int n = a.size();\n vector<pair<int,int>> temp(n);\n for(int i = 0;i<n;i++){\n temp[i] = {b[i],a[... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& a, vector<int>& b) {\n ios_base::sync_with_stdio(0);\n // cin.tie(NULL);\n // cout.tie(NULL);\n int n = a.size();\n vector<pair<int,int>> temp(n);\n for(int i = 0;i<n;i++){\n temp[i] = {b... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n=plantTime.size();\n vector<pair<int,int>>temp(n);\n for(int i=0;i<n;i++){\n temp[i].first=growTime[i];\n temp[i].second=plantTime[i];\n }\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size(), ans = 0;\n vector<pair<int,int>> arr(n);\n for (int i=0;i<n;i++){\n arr[i] = {growTime[i]+1, plantTime[i]};\n }\n sort(arr.rbegin()... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& a, vector<int>& b) {\n cin.tie(NULL);\n cout.tie(NULL);\n int n = a.size();\n vector<pair<int,int>> temp(n);\n for(int i = 0;i<n;i++){\n temp[i] = {b[i],a[i]};\n }\n sort(temp.rbeg... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n\tint earliestFullBloom(std::vector<int>& plantTime, std::vector<int>& growTime) {\n\t\tstd::vector<std::pair<int, int>> grow_do(plantTime.size());\n\t\tfor (int i = 0; i < plantTime.size(); i++)\n\t\t{\n\t\t\tgrow_do[i] = {growTime[i], plantTime[i]};\n\t\t}\n\t\tstd::stable_sort... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n bool static cmp(pair<int,int> a,pair<int,int> b){\n return a.first > b.first;\n }\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n\n vector<pair<int,int>> v;\n for(int i=0;i<plantTime.size();i++){\n v... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\n static bool cmp(pair<int,int> a,pair<int,int> b)\n {\n return a.second > b.second;\n }\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> map;\n for(int i = 0;i < plantTime.size();i++)\n {\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\nstatic bool comp(pair<int,int>p1,pair<int,int>p2){\n if(p1.second>p2.second){\n return true;\n }\n return false;\n}\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> v;\n for(int i=0;i<plantTime.size(... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "struct Seed {\n int p;\n int g;\n};\n\nclass Solution {\n public:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int ans = 0;\n int time = 0;\n vector<Seed> seeds;\n\n for (int i = 0; i < plantTime.size(); ++i)\n seeds.emplace_back(plantTime[i], growTime[i]);... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n static bool comp(const pair<int, int> p1, const pair<int, int> p2){\n if(p1.first > p2.first) return true;\n if (p1.first < p2.first) return false;\n return p1.second > p2.second;\n }\n int earliestFullBloom(vector<int>& p, vector<int>& g) {\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>>vec;\n for(int i=0;i<plantTime.size();i++){\n vec.push_back({growTime[i],plantTime[i]});\n }\n sort(vec.begin(),vec.end(),greater<pair<int,int>... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int i, plantdays=0, growdays=0;\n\n vector<pair<int,int>> arr;\n for(i=0 ; i<plantTime.size() ; i++)\n {\n arr.push_back(make_pair(growTime[i], plantTime[i]));\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 1 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int i, plantdays=0, growdays=0;\n\n vector<pair<int,int>> arr;\n for(i=0 ; i<plantTime.size() ; i++)\n {\n arr.push_back(make_pair(growTime[i], plantTime[i]));\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 2 | {
"code": "#include<bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n static bool fun(pair<int, int> &a, pair<int, int> &b) {\n return a.second > b.second;\n }\n\n int earliestFullBloom(vector<int>& p, vector<int>& g) {\n vector<pair<int, int>> v;\n for (int i = 0; i < ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 2 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> vec; // plantTime[i] growTime[i]\n int n = plantTime.size();\n for(int i =0; i<n; i++){\n vec.push_back({plantTime[i],growTime[i]});\n }\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n map<int, vector<int>> mp;\n for (int i = 0; i < plantTime.size(); i++) {\n mp[growTime[i]].push_back(i);\n }\n int time = 0;\n int res = 0;\n for (aut... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n//in real life we will plant the tree that will take max time to grow so that \n//when we are done planting all seeds it would have grown significanlty\ntypedef pair<int, int> pp;\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n std::ios::sync_... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n\t\tint n = plantTime.size();\n vector<pair<int,int>>v;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tv.push_back({growTime[i],plantTime[i]});\n\t\t}\n\t\tsort(v.rbegin(),v.rend());\n\t\tint ans = 0, tot = 0;\... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n//in real life we will plant the tree that will take max time to grow so that \n//when we are done planting all seeds it would have grown significanlty\ntypedef pair<int, int> pp;\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTi... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n=plantTime.size();\n vector<pair<int,int>> a;\n for(int i=0;i<n;i++){\n a.push_back({growTime[i],plantTime[i]});\n }\n sort(a.rbegin(),a.rend());\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> vt;\n int n = plantTime.size();\n for(int i=0;i<n;i++){\n vt.push_back({growTime[i]+1,plantTime[i]});\n }\n sort(vt.rbegin(),vt.rend())... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int, int>> v;\n for (int i=0; i<plantTime.size(); ++i) {\n v.push_back(make_pair(growTime[i], plantTime[i]));\n }\n\n sort(v.rbegin(), v.rend());\n\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n int n = plantTime.size();\n vector<pair<int,int>> vec(n);\n for(int i=0;i<n;i++) vec.push_back({plantTime[i], ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n vector<pair<int,int>>vec(n);\n\n for(int i=0; i<n; i++){\n \n vec.push_back({plantTime[i],growTime[i]});\n }... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n \n int n = plantTime.size();\n vector<pair<int, int>> v;\n for(int i = 0 ; i < n ; i++){\n v.push_back({growTime[i] , i});\n }\n sort(v.rbegin() , v.r... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& pt, vector<int>& gt) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n int n = pt.size();\n vector<pair<int,int>> vec(n);\n for(int i=0;i<n;i++){\n vec.push_... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& pt, vector<int>& gt) {\n int n = pt.size();\n vector<pair<int,int>> vec(n);\n for(int i=0;i<n;i++){\n vec.push_back({gt[i],pt[i]});\n }\n int ans = 0;\n sort(vec.rbegin(),vec.rend());\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n \n int n=plantTime.size();\n vector<pair<int,int>>combined(n);\n for(int i=0;i<n;i++){\n combined.push_back({growTime[i],plantTime[i]});\n }\n sort(co... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n //we store the sum,plantime,growtime in a max heap\n int n=plantTime.size();\n priority_queue<pair<int,pair<int,int>>>pq;\n int currDay=0;\n int maxi=0;\n for(in... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n#define ll long long\n#define pb push_back\n#define ff first\n#define ss second\n#define mp make_pair\n#define lb lower_bound\n#define ub upper_bound\n#define all(v) (v).begin(),(v).end()\n#define endl \"\\n\"\n int earliestFullBloom(vector<int>& pt, vector<int>& gt) {\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n\n\n priority_queue<pair<int,int>>pq;\n for(int i=0;i<plantTime.size();i++)\n {\n pq.push({growTime[i],plantTime[i]});\n }\n int n=plantTime.size();\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n // intuition: plant all longest grow time first\n vector<vector<int> > all(plantTime.size(), {0, 0});\n for(int i = 0; i < plantTime.size(); ++i){\n all[i][1] = plantTime[... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& pt, vector<int>& gt) {\n int n = pt.size();\n vector<vector<int>> arr(n);\n for (int i=0;i<n;i++) {\n arr[i] = {gt[i], pt[i]};\n }\n\n sort(begin(arr), end(arr), [](const vector<int>& a, const ve... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n=plantTime.size();\n vector<vector<int>>v(n);\n for(int i=0;i<n;i++){\n v[i]={growTime[i],plantTime[i]};\n }\n sort(v.rbegin(),v.rend());\n int ans=0;\n int start=0;\n int... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n multimap<int,int>mp;\n \n for(int i=0;i<plantTime.size();i++)\n {\n mp.insert({growTime[i],plantTime[i]});\n // mp[growTime[i]]=plantTime[i];\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& ptime, vector<int>& gtime) {\n int n=ptime.size();\n multimap<int,int>mp;\n for(int i=0;i<n;i++){\n mp.insert({gtime[i],ptime[i]});\n }\n \n int ans=0;\n int x=0;\n for(auto i... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n // std::map<int> dict;\n // for (int i = 0; i<plantTime.size();i++) {\n // dict(plantTime[i]) = growTime[i];\n // }\n // int init = 0;\n //int max = 0;\n // fo... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n return calcEnd(plantTime,growTime);\n }\nprivate:\n int calcEnd(vector<int>& plantTime, vector<int>& growTime) {\n std::multimap<int,int,greater<int>> map;\n for(int i = 0 ; i<... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n // std::map<int> dict;\n // for (int i = 0; i<plantTime.size();i++) {\n // dict(plantTime[i]) = growTime[i];\n // }\n // int init = 0;\n //int max = 0;\n // fo... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n return calcEnd(plantTime,growTime);\n }\nprivate:\n int calcEnd(vector<int>& plantTime, vector<int>& growTime) {\n std::multimap<int,int,greater<int>> map;\n for(int i = 0 ; i<... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n unordered_map<int ,stack<int>>mp;\n for(int i=0 ; i<plantTime.size() ; i++){\n mp[growTime[i]].push(plantTime[i]);\n }\n sort(growTime.begin() , growTime.end());\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n \n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<pair<int,int>> v;\n int i;\n int n=growTime.size();\n for(i=0;i<n;i++){\n v.push_back(make_pair(growTime[i],plantTime[i]));\n }\n sort(v.begin(),v.end());\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n static bool cmp(vector<int>& a,vector<int>& b)\n {\n return max(a[0]+a[1],a[0]+b[0]+b[1])<max(b[0]+b[1],a[0]+b[0]+a[1]);\n }\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n vector<vector<int>> v;\n int n=plantTime.size(... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n \n static bool cmp(vector<int>& a, vector<int>& b) {\n return a[0] > b[0];\n }\n\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n vector<vector<int>>arr;\n for(int i = 0; i < n; i++) {\... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n int n = plantTime.size();\n vector<vector<int>> v;\n for(int i=0;i<n;i++) v.push_back({growTime[i],plantTime[i]});\n sort(v.begin(),v.end(), greater<vector<int>>());\n ... |
2,257 | <p>You have <code>n</code> flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two <strong>0-indexed</strong> integer arrays <code>plantTime</code> and <code>growTime</code>, of length <code>n</code> each:</p>... | 3 | {
"code": "class Solution {\npublic:\n int earliestFullBloom(vector<int>& plantTime, vector<int>& growTime) {\n \n int n = plantTime.size();\n vector<vector<int>> growthAndPlantTime;\n\n for(int i=0; i<n; i++)\n {\n growthAndPlantTime.push_back({growTime[i], plantTime[i... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "#define ll long long\n\nclass Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n=questions.size();\n ll dp[n];\n for(int i=n-1;i>=0;i--){\n ll x = questions[i][0];\n if(i==n-1){\n dp[i]=questions[i][0];\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "long long dp[100005];\nclass Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = questions.size();\n dp[n] = 0;\n for(int ind = n - 1; ind >= 0; ind--){\n long long nt = dp[ind + 1];\n long long t = dp[min(ind + questions[ind]... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n(questions.size());\n long dp[n+100001];\n memset(dp,0,sizeof(dp));\n for (int i(n-1); i > -1; --i) {\n dp[i] = max(dp[i+1], questions[i][0]+dp[i+questions[i][1]+1]);\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\n long long dp[200005];\npublic:\n long long maxPointsRec(int i, vector<vector<int>>& questions) {\n if (i >= questions.size()) return 0;\n\n if (dp[i] >= 0) return dp[i];\n\n long long take = questions[i][0] + maxPointsRec(i+questions[i][1] + 1, questions);\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = int(questions.size());\n long long dp[2*100001];\n for (int i = 0; i < 2*100000; i++) dp[i] = 0;\n \n for (int i = 0; i < n; i++) {\n if (i > 0) dp[i] = max(dp[i], d... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n // long long func(vector<vector<int>>& questions, vector<long long>& dp,\n // int index) {\n // if (index >= questions.size()) {\n // return 0;\n // }\n // if (dp[index] != -1) {\n // return dp[index];\n // }... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = questions.size();\n vector<long long> dp(n, 0);\n dp[n - 1] = questions[n-1][0];\n int i=n-2;\n for(;i>=0;i--){\n dp[i] = max(dp[i+1], (i + questions[i][1] + 1 < n) ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = questions.size();\n vector<long long> dp(n, 0);\n dp[n - 1] = questions[n-1][0];\n int i=n-2;\n for(;i>=0;i--){\n long long carry = (i + questions[i][1] + 1 < n) ? d... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long f(int idx,int n,vector<vector<int>>& ar,vector<long long>& dp){\n if(idx>=n){\n return 0;\n }\n if(dp[idx] != -1) return dp[idx];\n long long sk = f(idx+1,n,ar,dp);\n long long sl = ar[idx][0]+f(idx+ar[idx][1]+1,n,ar,dp)... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 0 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = questions.size();\n vector<long long> dp(n, 0);\n\n dp[n - 1] = questions[n - 1][0];\n for (int i = n - 2; i >= 0; i--) {\n int points = questions[i][0];\n int p... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int n = questions.size();\n vector<long long> dp(n+1,0);\n\n for(int i = n-1;i>=0;i--){\n dp[i] = max(dp[i+1],questions[i][0] + dp[min(n,questions[i][1]+i+1)]);\n }\n\n retu... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n int n = questions.size();\n vector<long long> dp(n + 2, 0);\n for (int i = 1; i <= n; ++i) {\n dp[i] = questions[i - 1][0... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "static int io_opt = []() {\n std::ios::sync_with_stdio(false);\n return 0;\n}();\n\nclass Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n int l=questions.size();\n vector<long long> arr(l+1,0);\n arr[l-1]=questions[l-1][0];\n for(int i=l-2; i>... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "static int io_opt = []() {\n std::ios::sync_with_stdio(false);\n return 0;\n}();\n\nclass Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n const int num = questions.size();\n vector<long long> dp(num+1, 0);\n for (int i = num-1; i >= 0; --i){\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long help(vector<vector<int>>&questions,int idx,vector<int>& dp){\n if(idx>=questions.size())return 0;\n if(dp[idx]!=-1)return dp[idx];\n long long skip=0,take=0;\n skip=help(questions,idx+1,dp);\n take=help(questions,idx+questions[idx]... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n long long max_points = 0;\n vector<long long> maxPointsAt(questions.size());\n vector<int> last(questions.size());\n for(int i = 0;i < questions.size();i++){\n if(i > 0 && maxPoint... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n long long max_points = 0;\n vector<long long> maxPointsAt(questions.size());\n vector<int> last(questions.size());\n for(int i = 0;i < questions.size();i++){\n if(i > 0 && maxPoint... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& que) {\n long long ans=0;\n int n=que.size();\n vector<long long>dp(n,0);\n vector<long long>ma(n,0);\n for(int i=n-1;i>=0;i--){\n if(i+que[i][1]+1<n){\n dp[i]=que[i][0]+ma[... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n long long maxScore = 0;\n\n std::vector<long long> maxScores(questions.size(), 0);\n std::vector<long long> maxMax(questions.size(), 0);\n\n\n maxMax[questions.size() - 1] = questions[questio... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n long long maxScore = 0;\n\n std::vector<long long> maxScores(questions.size(), 0);\n\n std::vector<long long> maxMax(questions.size(), 0);\n\n // for (auto rit = questions.rbegin(); rit != qu... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n long long maxScore = 0;\n\n std::vector<long long> maxScores(questions.size(), 0);\n std::vector<long long> maxMax(questions.size(), 0);\n\n\n maxMax[questions.size() - 1] = questions[questio... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\nint n;\nlong long dp[100005];\nlong long f(vector<vector<int>>& q,int i)\n{\n if(i>=n) return 0;\n if(dp[i]!=-1) return dp[i];\n long long take=q[i][0]+f(q,i+q[i][1]+1);\n long long ntake=f(q,i+1);\n return dp[i]=max(take,ntake);\n}\n long long mostPoints(vecto... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n int n;\n long long t[100002];\n long long solve(vector<vector<int>>&questions, int i){\n if(i>=n) return 0;\n if(t[i]!=-1)\n return t[i];\n long long take=questions[i][0]+solve(questions,i+questions[i][1]+1);\n long long skip=solve(que... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long mostPoints(vector<vector<int>>& questions) {\n // can either add the thing or not\n // adding will reset it and the thing\n // how about for each question, you can look at the end index\n // so want to go through the dp thing\n con... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\nlong long dp[100001];\nlong long solve(int i,vector<vector<int>>& questions){\n if(i>=questions.size())return 0;\n if(dp[i]!=-1)return dp[i];\n // max points ke liye ya toh mai is question ko solve kr sakta hu ya skip;\n long long skip=solve(i+1,questions);\n l... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long dp[(int) 1e5 + 1];\n\n long long slv(int i, vector<vector<int>> &questions) {\n if (i >= questions.size())return 0;\n long long &ret = dp[i];\n if (~ret)return ret;\n ret = max(ret, slv(i + 1, questions));\n ret = max(ret, qu... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n long long int dp[100005];\n long long int f(int i,int n,vector<vector<int>>&arr)\n {\n if(i >= n) return 0;\n if(dp[i] != -1) return dp[i];\n long long int nottake = f(i+1,n,arr);\n long long int take = 0;\n\n take = arr[i][0] + f(i + ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n int n;\n long long solve(int i,vector<vector<int>>&v,vector<long long>&dp){\n if(i>=n)return 0;\n if(dp[i]!=-1)return dp[i];\n long long no=solve(i+1,v,dp);\n long long take=v[i][0]+solve(i+v[i][1]+1,v,dp);\n return dp[i]=max(no,take);\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n \n #define ll long long\n \n ll dp[200001] = {{0}};\n \n ll getPoints(int idx, vector<vector<int>>& questions, int n){\n \n if(dp[idx] != 0) return dp[idx];\n \n if(idx == n-1) return questions[idx][0];\n if(idx >= n) return 0... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 1 | {
"code": "class Solution {\npublic:\n vector<long long> dp;\n\n long long mostPoints(vector<vector<int>>& questions) {\n\n // Approach-1: (Using DP->Memoization)\n // T.C. --> O(n)\n // S.C. --> O(n)\n \n dp.resize(questions.size(), -1);\n\n return solve(0, questions);... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\n long long function(vector<vector<int>>& questions, int size, vector<long long> &dp){\n if(size <= 0) return 0;\n if(size == 1) return dp[size] = questions[size-1][0]; //if a single question, return the first element in that\n //case1, we can choose t... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\n long long find_points(vector<vector<int>>& questions, vector<long long>& dp, int i) {\n if (i >= questions.size()) return 0;\n if (dp[i] != 0) return dp[i];\n //index of next question we can solve if we solve curr question\n int next_question = i +... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "static int io_opt = []() {\n std::ios::sync_with_stdio(false);\n return 0;\n}();\n\nclass Solution {\npublic:\n int n;\n vector<long long> dp;\n\n long long solve(vector<vector<int>>& questions, int i){\n if(i>=n){\n return 0;\n }\n\n if(dp[i] != -1){\n ... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\n long long function(vector<vector<int>>& questions, int size, vector<long long> &dp){\n if(size <= 0) return 0;\n if(size == 1) return dp[size] = questions[size-1][0]; //if a single question, return the first element in that\n //case1, we can choose t... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\nlong long mostSum(long long idx,vector<vector<int>>& questions, vector<long> &dp) {\n if(idx >= questions.size())\n return 0;\n if(dp[idx]!= 0)\n return dp[idx];\n \n long long points = questions[idx][0];\n long long skip = questions[idx][1];\n lo... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\nlong long solve(int i,vector<vector<int>>&v,vector<long long>&dp)\n{\n if(i>=v.size())\n return 0;\n if(dp[i]!=-1)\n return dp[i];\n long long skip=solve(i+1,v,dp);\n long long attend=0;\n attend=solve(i+v[i][1]+1,v,dp)+v[i][0];\n return dp[i]= max(attend,... |
2,262 | <p>You are given a <strong>0-indexed</strong> 2D integer array <code>questions</code> where <code>questions[i] = [points<sub>i</sub>, brainpower<sub>i</sub>]</code>.</p>
<p>The array describes the questions of an exam, where you have to process the questions <strong>in order</strong> (i.e., starting from question <cod... | 3 | {
"code": "class Solution {\npublic:\n long long calculate(vector<vector<int>> &q, int pos, vector<long long >&dp){\n if(pos >= q.size()) {return 0; }\n long long t1 = 0, t2 = 0; \n if(dp[pos+1] == -1) dp[pos+1] = calculate(q, pos+1, dp); \n t1 = dp[pos+1]; \n if(pos+1+q[pos]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.