id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n struct job{\n int start;\n int end;\n int profit;\n };\n\n static bool comp(vector<int>& a, vector<int>& b){\n return a[0]<b[0];\n }\n\n int find_next(vector<vector<int>>& events,int endTime,int ind){\n int left = ind+1;\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "#include <vector>\n\nusing std::vector;\n\nclass Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n std::sort(\n events.begin(), events.end(),\n [](const vector<int>& a, const vector<int>& b) {\n if (a[1] == b[1]) {\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n\n int maxValue(vector<vector<int>>& events, int k) {\n\n int n = events.size();\n\n sort(events.begin(), events.end());\n\n vector<int> next(n, n);\n\n for (int i = 0; i < n; i++) {\n auto pt = lower_bound(events.begin(), events.end(), e... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n bool static cust(vector<int>&a , vector<int>&b){\n if(a[1]!=b[1])return a[1]<b[1];\n if(a[0]!=b[0])return a[0]<b[0];\n return a[2]>b[2];\n }\n int maxValue(vector<vector<int>>& e, int k) {\n\n vector<vector<pair<int,int>>>v(k+1);\n sor... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n vector<pair<int,pair<int,int>>> ev;\n vector<int> start;\n int n = events.size();\n for(int i =0;i<n;i++){\n ev.push_back({events[i][0],{events[i][1],events[i][2]}});\n star... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic: \n int calc(int idx, int k, vector<int> &nxtIdx, vector<vector<int>> &events, vector<vector<int>> &dp) {\n if (idx == events.size() || k <= 0) return 0; \n if (dp[idx][k] != -1) return dp[idx][k]; \n\n int notTake = calc(idx + 1, k, nxtIdx, events, dp); \n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n int n = events.size();\n // Sort events based on their starting time\n sort(events.begin(), events.end());\n\n // Extract starting times to perform binary search later\n vector<int> start_... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "int fast = []{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n return 0;\n}();\n\nclass Solution {\n int n;\n vector<vector<int>> dp;\n \n int fun(int i, int k, vector<vector<int>> &arr) {\n if (i >= n || k <= 0) return 0;\n if (dp[i][k] != -1) return dp[... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int gen(vector<vector<int>>&a,vector<vector<int>>&dp,int i,int prev,int k,int c){\n if(c==k || i==a.size()) return 0;\n if(prev>=a[i][0]) return gen(a,dp,i+1,prev,k,c);\n if(dp[c][i]!=-1) return dp[c][i];\n int res=max(gen(a,dp,i+1,prev,k,c),a[i][2... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\n int next(vector<vector<int>>& events, int l, int r, int time) {\n while (l<r) {\n int m=l+(r-l)/2;\n if (events[m][0]>time) r=m;\n else l=m+1;\n }\n return l;\n }\n int recurse(vector<vector<int>>& events, int k, int idx, vec... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int solve(int i,vector<vector<int>>& events, int k, vector<vector<int>> &dp){\n int n=events.size();\n if(k<=0 || i>=n ) return 0;\n if(dp[k][i]!=-1) return dp[k][i];\n int not_take=solve(i+1,events,k,dp),take=0;\n int j=i+1;\n for(;j... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n std::sort(events.begin(), events.end());\n // return backtrack(events, k, 0, 0);\n std::vector<std::vector<int>> memo(k+1, std::vector<int>(events.size(), -1));\n // return memoize(events, k, 0, ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n sort(events.begin(), events.end(), [](const vector<int>& a, const vector<int>& b) {\n return a[0] < b[0];\n });\n \n int n = events.size();\n vector<vector<int>> dp(k + 1, vecto... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n // sort(events.begin(), events.end(), [](const vector<int>& a, const vector<int>& b) {\n // return a[0] < b[0];\n // });\n sort(events.begin(), events.end());\n \n int n = event... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n bool static comp(vector<int> a,vector<int> b){\n if(a[1]==b[1]) return a[0]<b[0];\n return a[1]<b[1];\n }\n\n int f(int ind,int k,vector<vector<int>>& events,vector<int> &start_time,vector<vector<int>> &dp){\n if(k==0 || ind>=events.size()) return 0... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n int n = events.size();\n sort(events.begin(), events.end());\n vector<int> l;\n for(int i = 0; i < n; i++){\n l.push_back(events[i][0]); \n }\n\n vector<vector<int>> dp(... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "// class Solution {\n// public:\n// unordered_map<string,int> dp;\n// vector<vector<int>> v;\n// static bool cmp(vector<int> &a,vector<int> &b){\n// return a[0]<b[0];\n// }\n\n// int solverec(vector<int> &arr,int n,int i,int k){\n// if(i>=n)return 0;\n// if(k==0)return 0... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int n;\n int solve(int i,vector<vector<int>>& events,int k,vector<vector<int>> &dp){\n if(k<=0) return 0;\n if(i>=n) return 0;\n if(dp[k][i]!=-1) return dp[k][i];\n int take=0,not_take=0;\n //int ind=upper_bound(events.begin(),events.end(... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n int N = events.size();\n vector<pair<int, int>> endings;\n vector<vector<int>> f(N + 1, vector<int> (k + 2, 0));\n for (int i = 0; i < N; i ++) {\n endings.push_back(make_pair(events[i... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n int n = events.size();\n sort(events.begin(), events.end());\n vector<vector<int>> dp(n, vector<int> (k + 1));\n vector<int> nxt, v;\n for(int i = 0; i < n; i++)v.push_back(events[i][0]);\... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "bool customSort(vector<int>&a, vector<int>& b){\n if(a[0]<b[0]){\n return true;\n }\n else if(a[0]>b[0]){\n return false;\n }\n else{\n //Equal\n return a[1]<b[1];\n }\n}\nclass Solution {\n int checkNonOverlap(vector<vector<int>>& events, int idx){\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n vector<tuple<int, int, int>> v;\n int n = events.size();\n \n // Prepare the events in a sorted tuple form based on end time\n for (int i = 0; i < n; i++) {\n v.push_back({event... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n vector<tuple<int,int,int>>v;\n int n = events.size();\n for(int i = 0 ; i < n ; i ++){\n v.push_back({events[i][1],events[i][0],events[i][2]});\n }\n sort(v.begin(),v.end());\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\nvector<vector<int>> dp;\n int solve(int ind, int endTime, int k, vector<vector<int>>& events)\n {\n if(ind == size(events) || k == 0) return 0;\n\n if(events[ind][0] <= endTime) return solve(ind+1, endTime, k, events);\n if(dp[ind][k] != -1) return dp[i... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n sort(events.begin(), events.end(), [](const auto& a, const auto& b){\n return a[1]<b[1];\n });\n int n = events.size();\n vector<vector<int>> dp(n+1, vector<int>(k+1));\n for(in... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& e, int k) {\n\n int n=e.size();\n vector<vector<int>>dp(n+1,vector<int>(k+1,0));\n sort(e.begin(),e.end());\n for(int i=n-1;i>=0;i--){\n vector<int>x={e[i][1],(int)1e9,(int)1e9};\n int ind=low... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& e, int k) {\n\n int n=e.size();\n vector<vector<int>>dp(n+1,vector<int>(k+1,0));\n sort(e.begin(),e.end());\n for(int i=n-1;i>=0;i--){\n vector<int>x={e[i][1],(int)1e9,(int)1e9};\n int ind=low... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n sort(events.begin(), events.end(), [](const auto& a, const auto& b){\n return a[1]<b[1];\n });\n int n = events.size();\n vector<vector<int>> dp(n+1, vector<int>(k+1));\n for(in... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 0 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n sort(events.begin(), events.end(), [](const auto& a, const auto& b){\n return a[1]<b[1];\n });\n int n = events.size();\n vector<vector<int>> dp(n+1, vector<int>(k+1));\n for(in... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 1 | {
"code": "class Solution {\npublic:\n int f(int ind, int k, vector<vector<int>> &events, vector<vector<int>> &dp){\n if(ind == events.size() || k == 0){\n return 0;\n }\n if(dp[ind][k] != -1) return dp[ind][k];\n int take = events[ind][2];\n for(int i = ind+1; i < eve... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 1 | {
"code": "class Solution {\npublic:\n\nint BS(int index,vector<vector<int>>&events,int value)\n{\n int lo = index;\n int hi = events.size()-1;\n int req = -1;\n while(hi>=lo)\n {\n int mid = lo+(hi-lo)/2;\n if(events[mid][0] > value)\n {\n req = mid;\n hi = mid-1;\n }... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 1 | {
"code": "class Solution {\npublic:\n int n;\n vector<vector<int>> t;\n int solve(vector<vector<int>>& events, int i, int k) {\n \n if(k <= 0 || i >= n)\n return 0;\n \n int start = events[i][0];\n int end = events[i][1];\n int value = events[i][2];\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 1 | {
"code": "class Solution {\npublic:\n int nkstory(vector<vector<int>>& events, int k,int i,vector<vector<int>>&dp){\n if(i>=events.size()||k==0) return 0;\n if(dp[i][k]!=-1) return dp[i][k];\n int nontake=nkstory(events,k,i+1,dp);\n int j=i+1;\n for(;j<events.size();j++){\n if(event... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 2 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& e, int k) {\n vector<int> s;\n for(auto i : e) s.push_back(i[0]);\n sort(s.begin(), s.end()); // Sort the start times\n\n sort(e.begin(), e.end(), [](const vector<int>& a, const vector<int>& b){\n return ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 2 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& e, int k) {\n vector<int> s;\n for(auto i : e) s.push_back(i[0]);\n sort(s.begin(), s.end()); // Sort the start times\n\n sort(e.begin(), e.end(), [](const vector<int>& a, const vector<int>& b){\n return ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 2 | {
"code": "class Solution {\npublic: \n int n=0;\n vector<vector<int>>t;\n int solve(int idx,vector<vector<int>>& events,int k){\n if(k==0 || idx>=events.size()) return 0;\n // skip;\n if(t[idx][k]!=-1) return t[idx][k];\n int skip=solve(idx+1,events,k);\n int start=events[... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>>dp;\n int i;\n int pankaj(int ind, int k, vector<vector<int>> &events){\n if(ind >= (int)events.size() || k<1) return 0;\n if(dp[ind][k]!= -1) return dp[ind][k];\n for(i=ind+1;i<(int)events.size();i++) if(events[ind][1]<events[... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 2 | {
"code": "class Solution {\npublic:\n int maxEventValue(int currentIndex, int remainingEvents, const vector<vector<int>>& events, vector<vector<int>>& memo, vector<int>& ans) {\n if (currentIndex >= events.size() || remainingEvents == 0) return 0;\n\n if (memo[currentIndex][remainingEvents] != -1) return me... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> memo;\n int maxValue(vector<vector<int>>& events, int k) {\n int n = events.size();\n memo.assign(n, vector<int>(k + 1, -1));\n sort(events.begin(), events.end());\n\n for(int i = 0;i<n;i++){\n vector<int> nextEven... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n int solve(int index, int left, vector<pair<pair<int,int>,int>>& v, int n, vector<vector<int>>& dp, vector<int>& nextIndex) {\n if (index == n || left == 0) {\n return 0;\n }\n\n if (dp[index][left] != -1) {\n return dp[index][left];\... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n static bool cmp(vector<int> &a, vector<int> &b){\n return a[2]>b[2];\n }\n\n int check(int idx, vector<vector<int>> &events, int curen){\n int lo = idx;\n int hi = events.size()-1;\n int ans = -1;\n while(lo<=hi){\n int mid ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n static bool comp(vector<int>&a,vector<int>&b){\n return a[0]<b[0];\n }\n int helper(int index, vector<vector<int>>& events, int k, vector<vector<int>>&dp){\n if(index>=events.size()||k==0)return 0;\n if(dp[index][k]!=-1)return dp[index][k];\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n\n int helper(int index, vector<vector<int>>& events, int k, vector<vector<int>>&dp){\n if(index>=events.size()||k==0)return 0;\n if(dp[index][k]!=-1)return dp[index][k];\n int ans = helper(index+1,events,k,dp);\n int j=events.size();\n for(i... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n vector<int>next;\n int f(int i,int rem,vector<vector<int>>& events,vector<vector<int>>&dp){\n if(i>=events.size()) return 0;\n if(rem==0) return 0;\n if (dp[i][rem] != -1) return dp[i][rem];\n\n int j=next[i];\n int pick=events[i][2]+f(j,... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n struct CompItem{\n bool operator()(const vector<int>& a,const vector<int>& b) const{\n return a[0] < b[0];\n }\n };\n int f(vector<vector<int>>& eList,int idx,int chance){\n if(chance == 0){\n return 0;\n }\n if(i... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "// class Solution {\n// public:\n// vector<vector<int>> dp;\n// int n;\n\n// int attend(int i, int num, vector<vector<int>>& events){\n// // Base case: If we have attended num events or reached the end of events list, return 0.\n// if (i == n || num == 0) return 0;\n\n// ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\nprivate:\n int solve(int cur, vector<vector<int>> &events, vector<int> &start, int k){\n if(k==0) return 0;\n if(cur>=events.size()) return 0;\n \n if(dp[cur][k]!=-1) return dp[cur][k];\n \n int pick=0; int notPick=0;\n \n int ind... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "#define ll long long int\nclass Solution {\npublic:\n int BS(int i,vector<vector<int>>&events,int val){\n int l=i;\n int h=events.size()-1;\n int ind=-1;\n while(l <= h){\n int mid=l+(h-l)/2;\n if(events[mid][0] > val){\n ind = mid;\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "#include <vector>\n#include <algorithm>\n\nclass Solution {\npublic:\n int solve(int i, int k) {\n if (i >= events.size()) {\n return 0;\n }\n if (k <= 0) {\n return 0;\n }\n if (cache[i][k] != -1) {\n return cache[i][k];\n }\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\nvector<vector<int>>dp;\n int f(int i,int k,vector<vector<int>>&events,vector<int>&arr){\n\n if(i==arr.size() || k==0){\n return 0;\n }\n if(dp[i][k]!=-1){\n return dp[i][k];\n }\n int index=upper_bound(arr.beg... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution { \n int lowerBound(vector<vector<int>> &job, int val) \n {\n int n = job.size() ; \n int low = 0, high = n - 1;\n int ans = n;\n\n while (low <= high) {\n int mid = (low + high) / 2;\n \n if (job[mid][0] > val) {\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n int n;\n vector<vector<int>> dp,a;\n int rec(int i,int k){\n if(i==n || k==0) return 0;\n if(dp[i][k]!=-1) return dp[i][k];\n \n int include=a[i][2];\n for(int j=i;j<a.size();j++){\n if(a[j][0]>a[i][1]){\n inc... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\nprivate:\n vector<vector<long>> dp;\npublic:\n long solve(long idx, long curr, long k, vector<vector<int>> &events){\n if(idx >= events.size() || curr >= k)\n return 0;\n if(dp[idx][curr] != -1)\n return dp[idx][curr];\n long nextIdx = idx ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n long long int solve(long long int indx,vector<vector<int>>&a,long long int k,long long int &n,vector<vector<long long int>>&dp){\n if(indx>=n){\n return k>=0?0:INT_MIN;\n }\n if(k<0) return INT_MIN;\n if(dp[indx][k]!=-1) return dp[indx][... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "#define ll long long int\nclass Solution {\npublic:\n vector<int>sr;\n ll f(vector<vector<int>>& v,int k,int i,vector<vector<ll>>& dp){\n if(i>=v.size()) return 0;\n if(k<=0) return 0;\n if(dp[i][k]!=-1) return dp[i][k];\n int ind=upper_bound(sr.begin(),sr.end(),v[i][1])-s... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "#define ll long long int\nclass Solution {\npublic:\n vector<int>sr;\n int BS(int i,vector<vector<int>>&events,int val){\n int l=i;\n int h=events.size()-1;\n int ind=-1;\n while(l<=h){\n int mid=l+(h-l)/2;\n if(events[mid][0]>val){\n i... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n // map<pair<int,int>,int>mpp;\n long long f(vector<vector<int>>& events,vector<int>&vec, int k,int ind, vector<vector<long long>>&dp)\n { \n\n if(k<0){\n return -1e9;\n }\n if(ind==events.size()){\n if(k>=0)return 0;\n\n ret... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n // dp[lev][k_left]\n vector<int> st;\n int n;\n vector<vector<int>> eve;\n vector<vector<int>> dp;\n int rec(int lev, int left){\n if(lev==n || left==0){\n return 0;\n }\n\n if(dp[lev][left]!=-1){\n return dp[lev][left... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n int solve(int i,int cnt,vector<int> &st,vector<int> &end,vector<int> &cost,vector<vector<int>> &dp){\n if(cnt == 0){\n return 0;\n }\n if(i >= st.size()){\n return 0;\n }\n if(dp[i][cnt] != -1)return dp[i][cnt];\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\n struct eventData{\n int beg,end;\n long long int ben;\n int orderedIndex;\n //stores the orderedIndex of the nearest event after this one finishes\n int nearestEvent;\n\n eventData(int protoBeg, int protoEnd, int protoBen){\n beg = ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "\n\n\n// STL C++\n#include <bits/stdc++.h>\nusing namespace std;\n\n// GNU C++\n#include <ext/pb_ds/assoc_container.hpp> \n#include <ext/pb_ds/tree_policy.hpp> \nusing namespace __gnu_pbds;\n\n// #include <ext/rope> //header with rope\n// using namespace __gnu_cxx; //namespace with rope and some additional... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n std::sort(events.begin(), events.end(), [](const std::vector<int>& a, const std::vector<int>& b) {\n return a[1] < b[1];\n });\n\n std::vector<std::vector<int>> dp = {{0, 0}};\n std::v... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n int maxValue(vector<vector<int>>& events, int k) {\n std::sort(events.begin(), events.end(), [](const std::vector<int>& a, const std::vector<int>& b) {\n return a[1] < b[1];\n });\n\n std::vector<std::vector<int>> dp = {{0, 0}};\n std::v... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>>dp;\n vector<vector<int>> events;\n vector<int>v;\n vector<int>next;\n int n, k;\n int solve(int i, int j) {\n if(i >= n) return 0;\n if(dp[i][j]!=-1) return dp[i][j];\n int l = next[i];\n int sol = INT_MIN;\n ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\n vector <vector<int>> d;\n int N, K;\n vector <int> bs;\n vector <vector<int>> dp;\npublic:\n\n static bool comparator(vector <int> &a, vector<int> &b){\n return a[0] < b[0];\n }\n\n int find_next_end_time(int idx){\n int x = d[idx][1];\n int l = ... |
1,851 | <p>You are given an array of <code>events</code> where <code>events[i] = [startDay<sub>i</sub>, endDay<sub>i</sub>, value<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> event starts at <code>startDay<sub>i</sub></code><sub> </sub>and ends at <code>endDay<sub>i</sub></code>, and if you attend this event, you will ... | 3 | {
"code": "class Solution {\n vector <vector<int>> d;\n int N, K;\n vector <int> bs;\n vector <vector<int>> dp;\npublic:\n\n static bool comparator(vector <int> &a, vector<int> &b){\n return a[0] < b[0];\n }\n\n int find_next_end_time(int idx){\n int x = d[idx][1];\n int l = ... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\npublic:\n bool check(int mid,vector<int>& dist, double hour){\n double cnt=0;\n for(int i=0;i<(int)(dist.size()-1);i++){\n cnt+=((dist[i]+mid-1)/mid);\n }\n cnt+= dist[(dist.size()-1)]/(1.0*mid);\n cout<<mid<<\" \"<<cnt<<endl;\n retu... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\nprivate:\n int f(vector<int>&v,int speed)\n {\n int result = 0;\n for(int i=0;i<(v.size()-1);i++)\n {\n if((v[i]%speed)==0)\n {\n result += (v[i]/speed);\n }\n else\n {\n result... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\nprivate : \n bool predicateFn(vector<int>& dist , double hour , int mid){\n double timetaken=0;\n for(int i = 0 ; i < dist.size() ; i++){\n timetaken += ((1.0*dist[i])/mid);\n if(timetaken > hour ) return false;\n timetaken = ceil(timetake... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\nprivate : \n bool predicateFn(vector<int>& dist , double hour , int mid){\n double timetaken=0;\n for(int i = 0 ; i < dist.size() ; i++){\n timetaken += ((1.0*dist[i])/mid);\n if(timetaken > hour ) return false;\n timetaken = ceil(timetake... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\nprivate : \n bool predicateFn(vector<int>& dist , double hour , int mid){\n double timetaken=0;\n for(int i = 0 ; i < dist.size() ; i++){\n timetaken += ((1.0*dist[i])/mid);\n if(timetaken > hour ) return false;\n timetaken = ceil(timetake... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 0 | {
"code": "class Solution {\nprivate : \n bool predicateFn(vector<int>& dist , double hour , int mid){\n double timetaken=0;\n // for(int i = 0 ; i < dist.size();i++) {\n // timetaken += (1.0*dist[i])/mid;\n // timetaken = ceil(timetaken);\n // if(mid == 625000) cout ... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 1 | {
"code": "class Solution {\npublic:\n int minSpeedOnTime(vector<int>& dist, double hour) {\n int left = 0, right = 1e7 + 1;\n int n = dist.size();\n long long hr = llround(hour * 100);\n if (hr <= (n - 1) * 100) return -1;\n while (left + 1 < right) {\n int mid = left... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 1 | {
"code": "class Solution {\nprivate : \n bool predicateFn(vector<int>& dist , double hour , int mid){\n double timetaken=0;\n for(int i = 0 ; i < dist.size() ; i++){\n timetaken += ((1.0*dist[i])/mid);\n if(timetaken > hour ) return false;\n timetaken = ceil(timetake... |
2,000 | <p>You are given a floating-point number <code>hour</code>, representing the amount of time you have to reach the office. To commute to the office, you must take <code>n</code> trains in sequential order. You are also given an integer array <code>dist</code> of length <code>n</code>, where <code>dist[i]</code> describe... | 3 | {
"code": "class Solution {\npublic:\n int minSpeedOnTime(vector<int>& dist, double hour) {\n int n = dist.size(); \n int minSpeed = 1, maxSpeed = 1e7 + 1; \n int answer = -1; \n\n while (minSpeed < maxSpeed) { \n int midSpeed = minSpeed + (maxSpeed - minSpeed) / 2; \n\n ... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\n public:\n int minPairSum(vector<int>& nums) {\n int ans = 0;\n\n ranges::sort(nums);\n\n for (int i = 0, j = nums.size() - 1; i < j;)\n ans = max(ans, nums[i++] + nums[j--]);\n\n return ans;\n }\n};",
"memory": "98600"
} |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n ranges::sort(nums);\n int m=INT_MIN, i=0, j=nums.size()-1;\n while(i<=j)\n m=max(m, nums[i++]+nums[j--]);\n return m;\n }\n};\n\nstatic const int __ = [](){\n ios_base::sync_with_stdio(false);\... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\n public:\n int minPairSum(vector<int>& nums) {\n int ans = 0;\n\n ranges::sort(nums);\n\n for (int i = 0, j = nums.size() - 1; i < j;)\n ans = max(ans, nums[i++] + nums[j--]);\n\n return ans;\n }\n};",
"memory": "98900"
} |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\n public:\n int minPairSum(vector<int>& nums) {\n int ans = 0;\n\n ranges::sort(nums);\n \n\n for (int i = 0, j = nums.size() - 1; i < j;)\n ans = max(ans, nums[i++] + nums[j--]);\n\n return ans;\n }\n};",
"memory": "99000"
} |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums)\n {\n std::sort(nums.begin(), nums.end());\n \n int max_sum = 0;\n for (int i = 0; i < nums.size() / 2; i++) {\n int sum = nums[i] + nums[nums.size() - 1 - i];\n max_sum = std::max(max_sum, sum... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int n=nums.size(),maxPairSum=0;\n for(int i=0;i<n/2;i++) \n {\n int pairSum=nums[i]+nums[n-1-i];\n maxPairSum=max(maxPairSum, pairSum);\n }\n ... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a = 0;\n int max_sum = INT_MIN;\n while(a != nums.size()/2){\n if(nums[a]+nums[nums.size()-1-a] > max_sum){\n max_sum = nums[a]+nums[nums.size()-1-... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int i,j,sum;\n i=0;\n j=nums.size()-1;\n int n=nums.size()/2;\n int maxi=0;\n while(i<n)\n {\n sum=nums[i]+nums[j];\n maxi=max(... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(),nums.end());\n int i=0, j=n-1;\n int sol = 0;\n\n while(i<j){\n int sum = nums[i] + nums[j];\n sol = max(sum,sol);\n i++;\n ... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(),nums.end());\n int i=0, j=n-1;\n int sol = 0;\n\n while(i<j){\n int sum = nums[i] + nums[j];\n sol = max(sum,sol);\n i++;\n ... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a = 0;\n int max_sum = INT_MIN;\n while(a != nums.size()/2){\n if(nums[a]+nums[nums.size()-1-a] > max_sum){\n max_sum = nums[a]+nums[nums.size()-1-... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 0 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a = 0;\n int max_sum = INT_MIN;\n while(a != nums.size()/2){\n if(nums[a]+nums[nums.size()-1-a] > max_sum){\n max_sum = nums[a]+nums[nums.size()-1-... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 1 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int a = 0;\n int max_sum = INT_MIN;\n while(a != nums.size()/2){\n if(nums[a]+nums[nums.size()-1-a] > max_sum){\n max_sum = nums[a]+nums[nums.size()-1-... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 1 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(),nums.end());\n int i=0, j=n-1;\n int sol = 0;\n\n while(i<j){\n int sum = nums[i] + nums[j];\n i++;\n j--;\n sol = max... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.rbegin() , nums.rend());\n int left = 0 , right = (int) nums.size() - 1;\n int res = 0;\n while(left < right){\n int sumTotal = nums[left] + nums[right];\n res = max(res , sumTot... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.rbegin() , nums.rend());\n int left = 0 , right = (int) nums.size() - 1;\n int res = 0;\n while(left < right){\n res = max(res , max(nums[left] + nums[right] , nums[left + 1] + nums[right -... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.rbegin() , nums.rend());\n int left = 0 , right = (int) nums.size() - 1;\n int res = 0;\n while(left < right){\n int sumTotal = nums[left] + nums[right];\n res = max(res , sumTot... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n sort(nums.rbegin() , nums.rend());\n int left = 0 , right = (int) nums.size() - 1;\n int res = 0;\n while(left < right){\n res = max(res , max(nums[left] + nums[right] , nums[left + 1] + nums[right -... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int> nums) {\n sort(nums.begin(), nums.end());\n int pairSum = INT_MIN, n = nums.size();\n for (int i=0; i < n/2; i++) {\n pairSum = max(pairSum, nums[i] + nums[n-1-i]);\n }\n return pairSum;\n }\n};",
"... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n vector<int> temp(nums.size());\n temp=nums;\n\n int len=temp.size();\n std::sort(temp.begin(),temp.end());\n int max=temp[0]+temp[len-1];\n\n for(int i=1,j=len-2;i<=j;i++,j--){\n int su... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n int i=0;\n int j=n-1;\n vector<int> ans;\n while(i<=j){\n int sum=nums[i]+nums[j];\n ans.push_back(sum);\n i+... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(),nums.end());\n int i=0, j=n-1;\n vector<int> sol;\n\n while(i<j){\n int sum = nums[i] + nums[j];\n sol.push_back(sum);\n i++;\n ... |
1,988 | <p>The <strong>pair sum</strong> of a pair <code>(a,b)</code> is equal to <code>a + b</code>. The <strong>maximum pair sum</strong> is the largest <strong>pair sum</strong> in a list of pairs.</p>
<ul>
<li>For example, if we have pairs <code>(1,5)</code>, <code>(2,3)</code>, and <code>(4,4)</code>, the <strong>max... | 3 | {
"code": "class Solution {\npublic:\n int minPairSum(vector<int>& nums) \n {\n sort(nums.begin(),nums.end());\n vector<int>ans;\n int l=0,r=nums.size() - 1;\n int sum = 0;\n while(l < r)\n {\n sum = nums[l] + nums[r];\n ans.push_back(sum);\n ... |
2,107 | <p>Given an array of strings <code>nums</code> containing <code>n</code> <strong>unique</strong> binary strings each of length <code>n</code>, return <em>a binary string of length </em><code>n</code><em> that <strong>does not appear</strong> in </em><code>nums</code><em>. If there are multiple answers, you may return <... | 0 | {
"code": "class Solution {\npublic:\n string findDifferentBinaryString(vector<string>& nums) {\n int n = nums.size();\n string ans = \"\";\n for(int i=0; i<n; i++){\n if(nums[i][i] == '0') ans.push_back('1');\n else ans.push_back('0');\n }\n return ans;\n ... |
2,107 | <p>Given an array of strings <code>nums</code> containing <code>n</code> <strong>unique</strong> binary strings each of length <code>n</code>, return <em>a binary string of length </em><code>n</code><em> that <strong>does not appear</strong> in </em><code>nums</code><em>. If there are multiple answers, you may return <... | 0 | {
"code": "class Solution {\npublic:\n string findDifferentBinaryString(vector<string>& v) {\n string ans;\n for(int i = 0 ; i < v.size(); i++){\n if(v[i][i] == '0'){\n ans.push_back('1');\n }\n else{\n ans.push_back('0');\n }\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.