id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n = healths.size();\n // pos_hea_dir_num\n vector<vector<int>> v;\n for(int i=0;i<n;i++)v.push_back({positions[i],healths[i],(directions[i] =... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n \n stack<pair<int,int>> stk;\n\n unordered_map<int, int> originalPositions;\n for (int i = 0; i < positions.size(); i++) {\n originalP... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n \n stack<pair<int,int>> stk;\n\n unordered_map<int, int> originalPositions;\n for (int i = 0; i < positions.size(); i++) {\n originalP... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<vector<int>> v;\n for(int i=0;i<positions.size();i++){\n v.push_back({positions[i],healths[i],directions[i]=='R'?1:-1});\n }\n ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<vector<int>> robots;\n int n = positions.size();\n\n for(int i = 0; i < n; i++) robots.push_back({ positions[i], (directions[i] == 'L'), healths[... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<vector<int>> robots;\n int n = positions.size();\n\n for(int i = 0; i < n; i++) robots.push_back({ positions[i], (directions[i] == 'L'), healths[... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions,\n vector<int>& healths, string directions) {\n\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n\n\n ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<vector<int>> memo; // index, pos, health, direction (1 - R, 0 - L);\n int n = positions.size();\n for (int i = 0; i < n; i++) {\n int ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n stack<int> lstack;\n stack<int> rstack;\n int n = positions.size();\n vector<vector<int>> v;\n for(int i=0;i<n;i++){\n v.push_b... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& position, vector<int>& health , string directions) {\n int n = position.size() ;\n vector<int> ans(n) ;\n\n unordered_map<int , int> mp ;\n\n vector<vector<int>> robots ;\n for(int i=0 ; i<n ; i... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<int> ans(positions.size(),0);\n vector<vector<int>> rob;\n map<int,int> mp;\n for(int i=0; i<positions.size(); i++){\n mp[posit... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\n\npublic:\n static bool cmp(pair<int, int> a, pair<int, int> b) {\n return a.second < b.second;\n }\n\n vector<int> survivedRobotsHealths(vector<int>& positions,\n vector<int>& healths, string directions) {\n unordered_map<int, i... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\n \n \npublic:\n \n static bool cmp(pair<int,int>a,pair<int,int>b){\n return a.second<b.second;\n }\n \n\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n unordered_map<int, int> index;\n stack<pair<int,... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<int>ans;\n vector<vector<int>>v;\n for (int i=0;i<positions.size();i++)\n {\n v.push_back({positions[i],healths... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n \n vector<int> survivedRobotsHealths(vector<int>& pos, vector<int>& healths, string dirs) {\n int n = pos.size();\n vector<vector<int>> v;\n for (int i=0; i<n;i++){\n int p = pos[i], h = healths[i], dir = dirs[i]-'A';\n v.push_bac... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n unordered_map<long long,vector<long long>> t;\n vector<int> k=positions;\n sort(k.begin(),k.end());\n for(int i=0;i<positions.size();i++){\n ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "bool cmp(vector<int>v1,vector<int>v2)\n{\n\n return v1[0]<v2[0];\n}\nbool cmp1(vector<int>v1,vector<int>v2)\n{\n\n return v1[3]<v2[3];\n}\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n = positions.siz... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "bool cmp(pair<int, int>& a, pair<int, int>& b) {\n return a.second < b.second;\n}\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& pos, vector<int>& hlth, string dir) {\n int n = dir.size();\n stack<pair<int, int>> st;\n vector<pair<int, int>> ans;\n ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n map<int, int> health;\n map<int, string> direction;\n for(int i = 0;i < positions.size();i++) {\n health[positions[i]] = healths[i];\n ... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n stack<int> s; // Stack to store indices of robots\n unordered_map<int, char> directionMap; // Map positions to directions\n unordered_map<int, int> heal... |
2,846 | <p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p>
<p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron... | 3 | {
"code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n // check for l\n int n=positions.size();\n vector<pair<vector<int>,char>>v;\n for(int i=0;i<n;i++){\n v.push_back({{positions[i],hea... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\n public:\n int maxIceCream(vector<int>& costs, int coins) {\n ranges::sort(costs);\n\n for (int i = 0; i < costs.size(); ++i)\n if (coins >= costs[i])\n coins -= costs[i];\n else\n return i;\n\n return costs.size();\n }\n};",
"memory": "79000"
} |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\n public:\n int maxIceCream(vector<int>& costs, int coins) {\n ranges::sort(costs);\n\n for (int i = 0; i < costs.size(); ++i)\n if (coins >= costs[i])\n coins -= costs[i];\n else return i;\n return costs.size();\n }\n};",
"memory": "79100"
} |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(costs.begin(),costs.end());\n int ans=0;\n for(int i=0;i<costs.size();i++)\n {\n if(coins>=costs[i])\n {\n coins-=costs[i];\n ans++;\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(costs.begin(),costs.end());\n int cnt = 0;\n for(int i=0;i<costs.size();i++){\n if(coins>=costs[i]){\n coins = coins - costs[i];\n cnt++;\n }\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(costs.begin(),costs.end());\n int cnt = 0;\n for(int i=0;i<costs.size();i++){\n if(coins>=costs[i]){\n coins = coins - costs[i];\n cnt++;\n }\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(begin(costs), end(costs));\n int n = costs.size(), count = 0;\n for(int i = 0; i < n; i++){\n if(coins < 0) return count;\n count += (costs[i] <= coins);\n coins -= c... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coforins) {\n sort(costs.begin(),costs.end());\n int c=0;\n for(auto i:costs)\n {\n if(i<=coforins)\n {\n c+=1;\n coforins-=i;\n }\n }\n return c;... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int count=0;\n sort(costs.begin(),costs.end());\n for(int i=0;i<costs.size();i++){\n if(costs[i] <= coins){\n coins-=costs[i];\n count++;\n }\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 0 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int n = costs.size();\n sort(costs.begin(),costs.end());\n int i = 0;\n long long int cnt = 0;\n while(i<n){\n if(costs[i]<=coins){\n cnt++;\n }\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 2 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int n = costs.size();\n sort(costs.begin(),costs.end());\n int count = 0;\n for(int i=0; i<n;i++){\n if(costs[i]<=coins){\n count++;\n coins -= costs[i];\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n int ans=0;\n sort(begin(costs),end(costs));\n\n for(int i=0;i<costs.size();i++){\n if(costs[i]<=coin... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(costs.begin(),costs.end());\n int count = 0;\n\n for(int i=0;i<costs.size();i++){\n if(coins >= costs[i]){\n count++;\n coins -= costs[i];;\n }\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int c=0;\n int c1=0;\n vector<int>res;\n sort(costs.begin(),costs.end());\n for(int i=0;i<costs.size();i++){\n if(costs[i]<coins and c<=coins){\n c=c+costs[i];\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n //GREEDY - Always choose the lowest cost ice cream with budget remaining\n int maxCost = 0;\n int minCost = INT_MAX;\n\n for (int i=0; i<costs.size(); i++) {\n maxCost = max(maxCost, cos... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n //GREEDY - Always choose the lowest cost ice cream with budget remaining\n int maxCost = 0;\n int minCost = INT_MAX;\n\n //First extract range of count array \n for (int i=0; i<costs.size();... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "int compare(const void* a, const void* b)\n{\n\tconst int* x = (int*) a;\n\tconst int* y = (int*) b;\n\n\tif (*x > *y)\n\t\treturn 1;\n\telse if (*x < *y)\n\t\treturn -1;\n\n\treturn 0;\n}\n\nclass Solution {\npublic:\n\n int maxIceCream(vector<int>& costs, int coins) {\n int price = 0;\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int max_el = *max_element(costs.begin(), costs.end());\n vector<int> count(max_el + 1, 0);\n for (const int &cost : costs) {\n count[cost]++;\n }\n\n int cnt = 0;\n for (in... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int max = INT_MIN;\n long long bars = 0;\n for(int i = 0; i < costs.size(); i++)\n {\n if(max < costs[i])\n max = costs[i];\n }\n\n vector<int> cs = vector<i... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n const auto mx = *max_element(costs.begin(), costs.end());\n vector<int> freq(mx+1);\n for (auto c : costs) {\n freq[c]++;\n }\n auto ans = 0;\n\n for (auto c=1;c<=mx;c++) {... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int result = 0;\n int highestNumOfCoins = *max_element(costs.begin(), costs.end());\n\n vector<int> countArray(highestNumOfCoins + 1);\n\n for(int cost : costs){\n countArray[cost]++;\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int maxCount=*max_element(costs.begin(),costs.end());\n vector<int> countArray(maxCount+1,0);\n for(auto i: costs){\n countArray[i]++;\n }\n int maxice=0;\n for(int i=1;i<=... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n std::ios::sync_with_stdio(0);\n int ans = 0;\n int n = costs.size();\n int maxCost = *max_element(costs.begin(), costs.end());\n vector<int> st(maxCost + 1, 0);\n for (int num : costs... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int n = costs.size();\n int cnt = 0;\n priority_queue<int, vector<int>, greater<int>> pq(\n costs.begin(), costs.end()); // Floyeds heapify Algorithm\n while (coins > 0 && !pq.empty()) {... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n priority_queue<int,vector<int>,greater<int>> heap(costs.begin(),costs.end());\n while(coins>0 && !heap.empty()){\n if(coins>=heap.top()){\n coins-=heap.top();\n heap.pop(... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n vector<int> countSort(vector<int> &input) {\n int N = input.size();\n int M = 0;\n\n for(int i = 0; i < N; i++) {\n M = max(M, input[i]);\n }\n\n vector<int> countArray(M + 1, 0);\n\n for(int i = 0; i < N; i++) {\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n vector<int> countSort(vector<int>& inputArray){\n int N = inputArray.size();\n int M = *max_element(inputArray.begin(),inputArray.end());\n vector<int> countArray(M + 1, 0);\n for (int i = 0; i < N; i++)\n countArray[inputArray[i]]++;\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n vector<int> countSort(vector<int> &c, int &m){\n vector<int> tmp(m+1, 0);\n for(int i : c){\n tmp[i]++;\n }\n int rem = 0;\n for(auto it = tmp.begin(); it != tmp.end(); it++){\n int t = *it;\n *it = rem;\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n vector<int> countingSort(vector<int>&costs){\n int n = costs.size();\n int m = *max_element(costs.begin(),costs.end());\n vector<int>count(m+1,0);\n for(auto ele : costs)count[ele]++;\n for(int i = 1 ; i < m+1;i++)count[i]+=count[i-1];\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n int n=costs.size();\n int ans=0;\n int maxi=0;\n for(int i=0;i<n;i++){\n maxi=max(maxi,costs[i]);\n }\n\n vector<int> count(maxi+1,0);\n\n for(int i=0;i<n;i++){\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n sort(costs.begin(), costs.end());\n vector<long long> cst(costs.size(), 0);\n \n cst[0] = costs[0];\n for(int i=1; i<costs.size(); i++){\n cst[i] = costs[i] + cst[i-1];\n }... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) \n {\n int n=costs.size();\n sort(costs.begin(), costs.end());\n vector<long long> vec(n);\n vec[0]=costs[0];\n for(int i=1;i<n;i++) vec[i] = vec[i-1] + costs[i];\n\n long long lb = lo... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define lop(i, n) for (long long i = 0; i < n; i++)\n#define lopr(i, n) for (long long i = n - 1; i >= 0; i--)\n#define loop(i, a, b) for (long long i = a; i < b; i++)\n\nauto init = []()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n int maxIceCream(vector<int>& costs, int coins) {\n vector<int> vec(costs.size()); \n sort(costs.begin(), costs.end());\n\n for(int i = 0; i < costs.size(); ++i) {\n vec.push_back(costs[i]);\n }\n\n int cnt = 0;\n for(int i ... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n\n void countingSort(vector<int>& nums)\n {\n // step 1: find max number O(n)\n int max_num = 0;\n for(int i = 0; i < nums.size(); ++i)\n max_num = max(max_num, nums[i]);\n\n // step 2: map frequncies O(n)\n vector<int> freq(max... |
1,961 | <p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy ini... | 3 | {
"code": "class Solution {\npublic:\n\n void countingSort(vector<int>& nums)\n {\n // step 1: find max number O(n)\n int max_num = 0;\n for(int i = 0; i < nums.size(); ++i)\n max_num = max(max_num, nums[i]);\n\n // step 2: map frequncies O(n)\n vector<int> freq(max... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n auto cpm_queue = [&tasks](int i, int j) {\n if (tasks[i][1] == tasks[j][1]) return i > j;\n return tasks[i][1] > tasks[j][1];\n };\n priority_queue<i... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class custom {\npublic:\n bool operator()(pair<int, int>& a, pair<int, int>& b) {\n if (a.first > b.first) {\n return true;\n } else if (a.first == b.first) {\n if (a.second > b.second) {\n return true;\n } else {\n return fals... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n // sort the task based on enqueueTime, then process time, then idx\n // priority queue to choose task (1. compare process time, 2. compare idx)\n // put the first task into pq\n // time = enqueue... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "using vi = vector<int>;\nusing vvi = vector<vi>;\n\nclass Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n vi res, idx(tasks.size());\n priority_queue<pair<int, int>> pq;\n iota(idx.begin(), idx.end(), 0);\n sort(idx.begin(), idx.end(), [&](int i, in... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "#include <vector>\n#include <queue>\n#include <algorithm>\n\nclass Solution {\npublic:\n std::vector<int> getOrder(std::vector<std::vector<int>>& tasks) {\n int n = tasks.size();\n \n // Create a vector of indices and sort it based on the enqueue time\n std::vector<int> indic... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\nprivate:\n\n struct triple{\n int start;\n int duration;\n int index;\n\n triple(){\n start = 0;\n duration = 0;\n index = 0;\n }\n\n triple(int s, int d, int i){\n start = s;\n duration = ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n vector<int> index;\n for (int i = 0; i < n; i++) {\n index.emplace_back(i);\n }\n sort(index.begin(), index.end(), [&](const int& left, const int& right)... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n vector<int> index;\n for (int i = 0; i < n; i++) {\n index.emplace_back(i);\n }\n sort(index.begin(), index.end(), [&](const int& left, const int& right)... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n typedef pair<pair<int, int>, int> p; // { {enqueueTime, processingTime}, originalIndex }\n\n struct lambda {\n bool operator()(const p &p1, const p &p2) const {\n // Prioritize by processing time, then by original index\n if (p1.first.second ==... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n std::vector<std::tuple<int, int, int>> tasks_sorted(n);\n for(int i = 0; i < n; i++) {\n tasks_sorted[i] = std::tuple<int, int, int>(tasks[i][0], tasks[i][1], i);\n ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n vector<int> res;\n int n=tasks.size();\n vector<array<int,3>>sortedtask;\n for(int i=0;i<n;i++){\n sortedtask.push_back({tasks[i][0],tasks[i][1],i});\n\n }\n ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n using tuple_int = tuple<int, int, int>;\n using pair_int = pair<int, int>;\n priority_queue<tuple_int, vector<tuple_int>, greater<tuple_int>> pq;\n for(int i = 0; i<tasks.size();i++){\n ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n typedef pair<int,int> P;\n vector<int> getOrder(vector<vector<int>>& tasks) {\n vector<int> ans;\n vector<pair<int,pair<int,int>>> v;\n for (int i = 0; i < tasks.size(); i++) {\n v.push_back({tasks[i][0],{tasks[i][1],i}}); // {enque,process... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n std::ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;\n\n long long int time,n = ta... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "\nclass Solution {\npublic:\n struct Data {\n int et; // enqueue time\n int pt; // processing time\n int it; // index\n };\n vector<int> getOrder(vector<vector<int>>& tasks) {\n \n \n priority_queue<pair<int,int> , vector<pair<int,int>> ,greater<pair<int,in... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution \n{\nprivate:\n struct task\n {\n int id;\n int start;\n int burst_time;\n };\n static bool comp(task t1, task t2)\n {\n return t1.start<t2.start;\n }\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) \n {\n int n=tasks.siz... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n vector<int>res;\n priority_queue <pair<pair<int,int>,int>, vector<pair<pair<int,int>,int>>, greater<pair<pair<int,int>,int>>> q;\n priority_queue <pair<pair<int,int>,int>, vector<pair<pair<int,int... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 0 | {
"code": "#define ppi pair<int,pair<int,int>>\nclass Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n=tasks.size(),mx=0;\n vector<pair<int,pair<int,int>>>v;\n for(int i=0;i<n;i++){\n v.push_back({tasks[i][0],{tasks[i][1],i}});\n }\n sor... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 1 | {
"code": "class Solution {\npublic:\n // from λ¨μ μ루μ
γ
\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n for (int i = 0; i < n; ++i)\n tasks[i].push_back(i); //indexing all the tasks so they dont loose their identity\n sort(tasks.begin(),tasks.end()... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 1 | {
"code": "class Solution {\npublic:\n // from λ¨μ μ루μ
γ
\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n for (int i = 0; i < n; ++i)\n tasks[i].push_back(i); //indexing all the tasks so they dont loose their identity\n sort(tasks.begin(),tasks.end()... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n vector<int>ans;\n \n for(int i=0;i<tasks.size();i++){\n \n tasks[i].push_back(i);\n \n }\n sort(tasks.begin(),tasks.end());\n// \n vector<in... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n \n // monotonic queue queued<enqueueTime, processingTime, index>\n // min pq free <processing time, index>\n\n vector<array<int, 3>> sortedTasks;\n for (int i = 0; i < tasks.size(); i++)\n... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n for(int i = 0; i < tasks.size(); i++) {\n tasks[i].push_back(i);\n }\n \n sort(tasks.begin(), tasks.end());\n vector<int> ans;\n long long t = tasks[0][0];\n int i... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n for(int i = 0; i < tasks.size(); i++) {\n tasks[i].push_back(i);\n }\n \n sort(tasks.begin(), tasks.end());\n vector<int> ans;\n long long t = tasks[0][0];\n int i... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n priority_queue<pair<int,int> ,vector<pair<int,int>> , greater<pair<int,int>> > pq;\n int n = tasks.size();\n for(int i = 0; i < n; i++) {\n tasks[i].push_back(i);\n }\n stable_s... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Task {\n public:\n int index;\n int processing_time;\n int start_time;\n};\n\nclass Comp {\n public:\n bool operator()(Task* t1, Task* t2){\n if (t1->processing_time == t2->processing_time) return t1->index > t2->index;\n return t1->processing_time > t2->processing_tim... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n for(int i=0; i<tasks.size(); i++){\n tasks[i].push_back(i);\n }\n sort(tasks.begin(),tasks.end(),[](const vector<int>& a, const vector<int>& b){\n return a[0] < b[0];\n });\... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& t) {\n int n=t.size();\n vector<int>ans;\n priority_queue<pair<long long,int>>pq;\n for(int i=0;i<n;i++)t[i].push_back(i);\n sort(t.begin(),t.end());\n long long current=0;\n long long ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n for(int i=0; i<tasks.size(); i++){\n tasks[i].push_back(i);\n }\n sort(tasks.begin(),tasks.end(),[](const vector<int>& a, const vector<int>& b){\n return a[0] < b[0];\n });\... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n // sort(tasks.begin(), tasks.end());\n vector<int> ans, ind(tasks.size());\n iota(ind.begin(), ind.end(), 0);\n sort(ind.begin(), ind.end(), [&](int i1, int i2)->bool {\n return tasks[... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n=tasks.size();\n vector<tuple<long long,long long,int>> sortedTasks;\n for(int i=0; i<n; i++) {\n sortedTasks.push_back(make_tuple(tasks[i][0],tasks[i][1],i));\n }\n sort(s... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n typedef pair<int,int> P;\n\n vector<int> getOrder(vector<vector<int>>& tasks) {\n\n int n=tasks.size();\n \n vector<vector<int>> sortedTasks(n);\n\n for(int i=0;i<n;i++){\n sortedTasks[i]={tasks[i][0],tasks[i][1],i};\n }\n\n ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "\n#define pp pair<int,int> \n\n#define pp pair<int,int>\nclass Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n vector<vector<int>>v(n,vector<int>(3));\n for(int i = 0;i<n;i++){\n v[i][0]=tasks[i][0];\n v[i][1]=... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks2) {\n int n=tasks2.size();\n vector<vector<int>>tasks(n);\n for(int i=0;i<n;i++){\n tasks[i]={tasks2[i][0],tasks2[i][1],i};\n }\n sort(tasks.begin(),tasks.end());\n int i=0;\n... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "#define ll long long\nclass Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n for(int i=0; i < tasks.size(); i++){\n tasks[i].push_back(i);\n }\n sort(tasks.begin(),tasks.end());\n ll idx = 0 ;\n ll n = tasks.size();\n priorit... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n typedef pair<long long, pair<long long, long long>> p;\n\n struct cmp {\n bool operator()(p a, p b) {\n if (a.first == b.first) {\n return a.second.first > b.second.first;\n } else {\n return a.first > b.first;\n ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n priority_queue< pair<int, int>, vector<pair<int, int>>, greater<> > pq; //min_heap\n vector<int> answer;\n\n vector<array<int,3>> taskOrdered;\n int n = tasks.size();\n\n for(int i = 0; i ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) \n {\n vector<array<int,3>>sorted_tasks;\n int i=0;\n int n=tasks.size();\n for(auto taks:tasks)\n {\n int starttime=taks[0];\n int endtime=taks[1];\n int i... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) \n {\n vector<array<int,3>>sorted_tasks;\n int i=0;\n int n=tasks.size();\n for(auto taks:tasks)\n {\n int starttime=taks[0];\n int endtime=taks[1];\n int i... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\nprivate:\n struct Task {\n unsigned long long enque_time;\n unsigned long long processing_time;\n int idx;\n };\n\n class TaskHeap {\n private:\n vector<Task>& heap;\n bool (*is_smaller) (Task&a, Task& b);\n\n void sift_down(int root) ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\nprivate:\n struct Task {\n unsigned long long enque_time;\n unsigned long long processing_time;\n int idx;\n };\n\n class TaskHeap {\n private:\n vector<Task>& heap;\n bool (*is_smaller) (Task&a, Task& b);\n\n void sift_down(int root) ... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\nprivate:\n struct Task {\n unsigned long long enque_time;\n unsigned long long processing_time;\n int idx;\n\n friend bool operator < (Task& a, Task& b) {\n return a.enque_time < b.enque_time;\n }\n };\n\n class TaskHeap {\n privat... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "class Solution {\nprivate:\n struct Task {\n unsigned long long enque_time;\n unsigned long long processing_time;\n int idx;\n\n friend bool operator < (Task& a, Task& b) {\n return a.enque_time < b.enque_time;\n }\n };\n\n class TaskHeap {\n privat... |
1,962 | <p>You are given <code>n</code>ββββββ tasks labeled from <code>0</code> to <code>n - 1</code> represented by a 2D integer array <code>tasks</code>, where <code>tasks[i] = [enqueueTime<sub>i</sub>, processingTime<sub>i</sub>]</code> means that the <code>i<sup>ββββββth</sup></code>ββββ task will be available to process a... | 2 | {
"code": "typedef pair<long long, long long> ii;\ntypedef long long ll;\n\nclass Solution {\npublic:\n vector<int> getOrder(vector<vector<int>>& tasks) {\n int n = tasks.size();\n deque<tuple<ll, ll, ll>> vec;\n for(int i = 0; i < n; i++){\n ll x = tasks[i][0], y = tasks[i][1];\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.