id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "\n#ifdef LOCAL_RUN\n#include \"debug_leet.h\"\n #else\n #define trace(...) ;\n #define dbg(...) ;\n #define dbgc(...) ;\n #define debug(x) ;\n #define debuga(a, n) ;\n #define debug2(x, y) ;\n #define debug3(x, y, z) ;\n #define debug4(x, y, z, w) ;\n #define debug5(a,b,c,d,e)...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(const vector<vector<int>>& points) {\n const int n = points.size();\n const int m = points[0].size();\n\n vector<long long> memo(points[0].cbegin(), points[0].cend());\n for(int i = 1; i < n; ++i){\n vector<int> best_...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(const vector<vector<int>>& points) {\n const int n = points.size();\n const int m = points[0].size();\n\n vector<long long> memo(points[0].cbegin(), points[0].cend());\n for(int i = 1; i < n; ++i){\n vector<int> best_...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\n typedef long long ll;\n typedef pair<ll, ll> prll;\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size(), m = points[0].size();\n \n vector<ll> prev(m), curr(m);\n for(int i=0; i<m; i++) prev[i] = points[n-1][i];\n\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "#define ll long long\n#define li pair<long long, int>\n#define mp make_pair\nclass Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n uint m = points.size();\n uint n = points[0].size();\n vector<li> pp(n);\n for (int i = 0; i < n; i++) {\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n =points.size(), m = points[0].size();\n if(n == 1){\n long long ans = 0;\n for(long long tt:points[0])ans = max(ans,tt);\n return ans;\n }\n vector<vector<p...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n // seems like a dp\n vector<vector<long long>> dp(points.size(), vector<long long>(points[0].size(), 0));\n\n for (int j = 0; j < points[0].size(); j++) {\n dp[0][j] = points[0][j];\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "using ll = long long;\nclass Solution {\npublic:\n vector<vector<int>> v;\n // vector<vector<ll>> dp;\n // ll fun(ll r, ll c) {\n // if (r == n)\n // return 0;\n // ll& ret = dp[r][c];\n // if (ret!=-1)\n // return ret;\n // for (int i = 0; i < m; ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size();\n int m = points[0].size();\n \n if (n == 1) {\n return *max_element(points[0].begin(), points[0].end());\n }\n \n vector<long long> dp(m);\...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n #define ll long long\n long long maxPoints(vector<vector<int>>& points) {\n ll n = points.size();\n ll m = points[0].size();\n\n vector<ll> curr(points[0].begin(), points[0].end());\n\n if (n == 1) {\n return *max_element(curr.begin()...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxi(long long i, long long j){\n if(i>j) return i;\n return j;\n }\n // long long dp[1001][1001];\n long long fun(vector<vector<int>> &points, vector<vector<long long>> &dp){\n long long result = 0;\n for(int i = 0; i < points.s...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int row = points.size();\n int col = points[0].size();\n vector<long long> max_points;\n for(int i = 0; i < col; i++){\n max_points.push_back((long long) points[0][i]);\n //...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size(), m = points[0].size();\n vector<long long> ans;\n for (int p : points[0]) ans.push_back(p);\n for (int i = 0; i < n - 1; ++i) {\n vector<long long> left(m), right...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int m = points.size();\n int n = points[0].size();\n vector<long long> d1;\n for (int p: points[0]) d1.push_back(p);\n vector<long long> d2(n);\n vector<long long> &cur = d2, &prev = d1;\...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int m = points.size(), n = points[0].size();\n vector<long long> prev, curr(n, 0);\n for(auto i : points[0]) prev.push_back(i);\n\n for(int i = 1; i < m; i++){\n vector<long long> left...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int m = points.size();\n int n = points[0].size();\n vector<vector<long long>> dp(m, vector<long long>(n, 0));\n\n for (int i = 0; i < m; i++) {\n if (i == 0) {\n for (i...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int m = points.size(), n = points[0].size();\n vector<vector<long long>> dp(m, vector<long long>(n));\n for(int i = 0; i < n; i++)\n dp[0][i] = points[0][i];\n\n for(int i = 1; i < m; ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n long long mx = -1;\n int n = points.size(), m = points[0].size();\n cout << n << \" \" << m << endl;\n if (n == 1)\n return *max_element(points[0].begin(), points[0].end());\n v...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
1
{ "code": "class Solution {\npublic:\n long long maxPoints(std::vector<std::vector<int>>& points) {\n int m = points.size();\n int n = points[0].size();\n\n if (m == 1) {\n return *std::max_element(points[0].begin(), points[0].end());\n }\n\n // Initialize dp with valu...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int m = points.size(), n = points[0].size();\n\n std::vector<long long> score(points[0].begin(), points[0].end());\n\n for (int i = 1; i < m; i++) {\n std::vector<int> &row = points[i];\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\nvoid check(vector<vector<long long>>&dp,int curr_row,int row,int col,vector<vector<int>>&points){\n\n if(curr_row>=row){\n return ;\n }\n \n\n if(curr_row==row-1){\n for(int i=0;i<col;i++){\n dp[curr_row][i]=points[curr_row][i];\n }\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size();\n int m = points[0].size();\n vector<long long> previousRow;\n for(int i=0 ; i < m ; i++){\n previousRow.push_back(points[0][i]);\n }\n\n for(int r...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n // dp solution\n // int f(vector<vector<int>>& dp,vector<vector<int>>& points, int i, int prev_col){\n // if(i>=points.size()){\n // return 0;\n // }\n // if(dp[i][prev_col] != -1) return dp[i][prev_col];\n // int a = INT_MIN;\n //...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size();\n int m = points[0].size();\n vector<long long> prev(m, 0);\n \n for (int j = 0; j < m; ++j) {\n prev[j] = points[0][j];\n }\n for (int i = 1; i...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& points) {\n int n = points.size();\n int m = points[0].size();\n vector<long long> dp(m, 0);\n\n for (int j = 0; j < n; ++j) {\n vector<long long> new_dp(m, 0);\n vector<long long> left...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long util (vector<vector<int>> &p, int row, int lastCol, vector<vector<int>> &dp) {\n if (row == p.size()) return 0;\n\n if(dp[row][lastCol+1]!=-1) return dp[row][lastCol+1];\n long long ans=0;\n for (int i=0; i<p[0].size(); i++) {\n ...
2,067
<p>You are given an <code>m x n</code> integer matrix <code>points</code> (<strong>0-indexed</strong>). Starting with <code>0</code> points, you want to <strong>maximize</strong> the number of points you can get from the matrix.</p> <p>To gain points, you must pick one cell in <strong>each row</strong>. Picking the ce...
3
{ "code": "class Solution {\npublic:\n long long maxPoints(vector<vector<int>>& p) {\n int r = p.size();\n int c = p[0].size();\n \n // Create a dp array to store maximum points for each cell\n vector<vector<long long>> dp(r, vector<long long>(c, 0));\n \n // Initial...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
0
{ "code": "class Solution {\npublic:\n long long mostBooked(long long n, vector<vector<int>>& meetings) {\n if(meetings.size() == 1) return 0;\n vector<long long> endtime(n,0); \n vector<long long> count(n,0);\n sort(meetings.begin() , meetings.end());\n for(long long i = 0...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
0
{ "code": "class Solution {\npublic:\n long long mostBooked(int n, vector<vector<int>>& meetings) {\n if(meetings.size()==1){return 0;}\n vector<long long>endtime(n,0);//a vector to store the info about rroms\n vector<long long> count(n,0);//vector to store how many time rooms being used\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
1
{ "code": "typedef pair<long long,int>pi; //first num will be end time, second num will be room num\ntypedef vector<pi> vpi;\n // bool compare(pi a, pi b) \n // {\n // if(a.first>b.first)\n // return true;\n // if(a.first==b.first)\n // return a.second>b.second;\n // r...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
1
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);;\n std::vector<int> temp(n);\n for (int i = 0; i < n; ++i) {\n temp[i] = i;\n }\n std::priority_queue<int, std::vec...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
1
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n int m = meetings.size();\n vector <int> id(m);\n iota(begin(id), end(id), 0);\n sort(begin(id), end(id), [&](auto & x, auto & y) {\n return meetings[x][0] < meetings[y][0] || (meet...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
1
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<tuple<int, int>> sort_meetings(meetings.size());\n for (int i = 0; i < meetings.size(); ++i) {\n sort_meetings[i] = {meetings[i][0], meetings[i][1]};\n }\n sort(sort_meeting...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pq;\n sort(meetings.begin(), meetings.end());\n vector<int> ans(n, 0);\n an...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "#define ll long long\nclass Solution {\npublic:\n struct Compare{\n bool operator()(pair<ll,int>&x, pair<ll,int>&y){\n return x.second > y.second;\n }\n };\n int mostBooked(int n, vector<vector<int>>& meetings) {\n if(n==1){\n return 0;\n }\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<int> c(105, 0);\n sort(meetings.begin(), meetings.end());\n priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> q;\n for...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<pair<long long, long long>> meets(meetings.size());\n for (int i = 0; i < meetings.size(); i++) {\n meets[i] = { meetings[i][0], meetings[i][1] };\n }\n sort(meets.begin(), ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n\n struct Comp {\n bool operator()(pair<long long, long long>&a, pair<long long, long long>&b) {\n if(a.second != b.second) {\n return a.second > b.second;\n }\n return a.first > b.first;\n }\n };\n\n // void ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n\n struct Comp {\n bool operator()(pair<long long, long long>&a, pair<long long, long long>&b) {\n if(a.second != b.second) {\n return a.second > b.second;\n }\n return a.first > b.first;\n }\n };\n\n static b...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n struct Meeting {\n int64_t start;\n int64_t end;\n\n inline int64_t duration() const {\n return end - start;\n }\n\n inline bool operator<(const Meeting& other) const {\n return start > other.start;\n }\n };\n...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n struct Meeting {\n int64_t start;\n int64_t end;\n\n inline int duration() const {\n return end - start;\n }\n\n inline bool operator<(const Meeting& other) const {\n return start > other.start;\n }\n };\n\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n struct Meeting {\n int64_t start;\n int64_t end;\n\n inline int duration() const {\n return end - start;\n }\n\n inline bool operator<(const Meeting& other) const {\n return start > other.start;\n }\n };\n\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& m) {\n set<int> freeRooms; \n priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> endTimes;\n\n for(int i=0;i<n;i++)freeRooms.insert(i);\n \n sort(m.beg...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n // sort by start time\n sort(meetings.begin(), meetings.end());\n\n set<int> availables;\n for (int i = 0 ; i < n ; i++)\n availables.insert(i);\n\n priority_queue<pair<int,...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& m) {\n set<pair<int,int>> st;\n map<int,int> mp;\n for(int i=0;i<n;i++){\n st.insert({i, 0});\n }\n priority_queue<pair<long long,long long>, vector<pair<long long,long long>>, greater<pa...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n // time,index of allocated room\n priority_queue<pair<long long, int>, vector<pair<long long, int>>,\n greater<pair<long long, int>>>\...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>&nums) \n {\n sort(nums.begin(),nums.end());\n set<int>s;\n for(int i=0;i<n;i++)\n {\n s.insert(i);\n }\n priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pa...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n int m = meetings.size();\n sort(meetings.begin(), meetings.end());\n vector<int> room(n, 0);\n priority_queue<pair<long...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n int m = meetings.size();\n sort(meetings.begin(), meetings.end());\n vector<int> room(n, 0);\n priority_queue<pair<long...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\n using ll = long long;\n using pp = pair<ll, int>;\n\npublic:\n Solution() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "using pii = pair<long long, int>;\n\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n priority_queue<int, vector<int>, greater<int>> idle;\n priority_queue<pii, vector<pii>, greater<pii>> busy;\n for (int i = 0; i < n; i++) idle.push(i);\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<long long>cnt(n+1,0),nxt(n+1,0);\n sort(meetings.begin(),meetings.end());\n for(auto x:meetings){\n long long min_time = 1e18;\n int ind=-1;\n for(int i=1;i<=...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n int m = meetings.size();\n sort(meetings.begin(), meetings.end());\n priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;\n for (int i = 0; i ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n // brute force: traverse all start/end time(tic-tic)\n // maintain list of queue for each meeting room\n // each time, if a meeting begins, check list of queue\n // find lowest empty room\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n // brute force: traverse all start/end time(tic-tic)\n // maintain list of queue for each meeting room\n // each time, if a meeting begins, check list of queue\n // find lowest empty room\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<int> meetingCount(n, 0);\n priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> usedRooms;\n priority_queue<int, vector<int>, greater<int>> unused...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(),meetings.end());\n priority_queue<int, vector<int>, greater<int>> avlRoom;\n for(int i=0;i<n;i++){\n avlRoom.push(i);\n }\n priority_queue<pair<lo...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
2
{ "code": "bool compare(vector<int>& v1, vector<int>& v2) {\n return v1[0] < v2[0];\n}\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end(), compare);\n priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n struct Info {\n long long start, end;\n int room;\n Info(long long start, long long end, int room) : start(start), end(end), room(room) {}\n bool const operator<(const Info& ob) const {\n if(end == ob.end)return room > ob.room;\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(NULL);\n sort(meetings.begin(),meetings.end());\n vector<long long>roomcnt(n,0);\n priority_queue<long long,vector<long long>,grea...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n Solution(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(),meetings.end());\n priority_queue<pair<uint64_t,int>,vector<pair...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define F first\n#define S second\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<long long> v(n,0);\n sort(meetings.begin(),meetings.end());\n for (auto it : meetings){\n cout<<it[0]<<\" \"<<it[1]<<\"\\n\";\n }\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "\tstruct Meeting {\n\t\tint64_t start = 0;\n\t\tint64_t end = 0;\n\t\tint room = 0;\n\t};\n\n\tstruct Room {\n\t\tint id = 0;\n\t\tMeeting* meeting = nullptr;\n\t\tint64_t delay = 0;\n\t\tint uses = 0;\n\t};\n\n\tclass Solution {\n\tpublic:\n\t\tint mostBooked(int roomCount, vector<vector<int>>& intervals)...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "\tstruct Meeting {\n\t\tint64_t start = 0;\n\t\tint64_t end = 0;\n\t\tint room = 0;\n\t};\n\n\tstruct Room {\n\t\tint id = 0;\n\t\tMeeting* meeting = nullptr;\n\t\tint64_t delay = 0;\n\t\tint uses = 0;\n\t};\n\n\tclass Solution {\n\tpublic:\n\t\tint mostBooked(int roomCount, vector<vector<int>>& intervals)...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define pii pair<long long,int>\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n priority_queue<pii, vector<pii>, greater<pii>> pq;\n set<int> st;\n vector<int> mp(n, 0);\n\n for (int i = 0;...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n\n vector<int> cnt(n, 0);\n\n priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> pq;\n for (int i = 0; i < n; ++i)\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<int>cnt(n);\n set<int>s;\n for(int i = 0; i<n; i++){\n s.insert(i);\n }\n sort(meetings.begin(),meetings.end());\n priority_queue<pair<long long,int>,vector<pa...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#include <queue>\n\nstruct MeetingRoom {\n long int room_num;\n long int available_time;\n};\n\nstruct Meeting {\n long int start_time;\n long int end_time;\n};\n\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meeting_vects) {\n const auto compare_rooms = [&n]...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n struct Compare {\n bool operator()(const vector<long long>& a, const vector<long long>& b) {\n if (a[0] == b[0]) return a[1] > b[1];\n return a[0] > b[0];\n }\n };\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(mee...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n auto compare = [](vector<long long int>& a, vector<long long int>& b) {\n return a[0] > b[0];\n };\n priority_queue <vector<long long int>, vector<vector<long long int>>, greater<vector<l...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n priority_queue<pair<long, long>, vector<pair<long, long>>, greater<pair<long, long>>> events, pending;\n for (long i = 0; i < meetings.size(); i++) {\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n int m_sz = meetings.size();\n sort(meetings.begin(), meetings.end());\n \n set<pair<long long, int>> st; // < ending time, room no. >\n vector<int> v(n, 0); // freq of each room m...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n int m_sz = meetings.size();\n sort(meetings.begin(), meetings.end());\n \n set<pair<long long, int>> st; // < ending time, room no. >\n vector<int> v(n, 0); // freq of each room m...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n int m_sz = meetings.size();\n sort(meetings.begin(), meetings.end());\n \n set<pair<long long, int>> st; // < ending time, room no. >\n vector<int> v(n, 0); // freq of each room m...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define ll long long\nclass Solution {\npublic:\n \n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<int> rooms(n);\n \n sort(meetings.begin(), meetings.end());\n \n priority_queue<vector<ll>, vector<vector<ll>>, greater<>> using_room;\n prior...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(long long n, vector<vector<int>>& meetings) {\n vector<bool> flag(n, false);\n vector<long long> counter(n, 0);\n priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> ending_pq;...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n // int mostBooked(int n, vector<vector<int>>& nums) {\n // sort(nums.begin(),nums.end());\n // vector<int> fre(n,0);\n // vector<long long> end(n,0);\n // for(int i=0;i<nums.size();i++) {\n // bool flag = false;\n // for(int j...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define PLL pair<long, long>\n\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) \n {\n vector<long> roomCounter (n, 0);\n priority_queue<long, vector<long>, greater<long>> roomAvailabilityPQ;\n priority_queue<PLL, vector<PLL>, greater<PLL>> inProg...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define PLL pair<long, long>\n\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) \n {\n vector<long> roomCounter (n, 0);\n priority_queue<long, vector<long>, greater<long>> roomAvailabilityPQ;\n priority_queue<PLL, vector<PLL>, greater<PLL>> inProg...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define ll long long\nstruct Meeting{\n int start;\n ll end;\n Meeting(int start,ll end){\n this->start=start;\n this->end=end;\n }\n};\nstruct Room{\n int roomId;\n ll end;\n Room(int roomId, ll end){\n this->roomId=roomId;\n this->e...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define ll long long \n\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n vector<ll> ans(100, 0);\n ll maxi = 0, room = 0;\n priority_queue<ll, vector<ll>, greater<ll>> pq1;...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>> > onHold, busyRooms, toAdd;\n priority_queue<long long, vector<long long>, greater<long lo...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(), meetings.end());\n vector<int> count(n, 0);\n priority_queue<vector<long long int>, vector<vector<long long int>>, greater<vector<long long int>>>\n pq;\n pq...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\n struct cmp {\n bool operator()(vector<long long>& a, vector<long long>& b) {\n if (a[1] == b[1]) {\n return a[2] > b[2];\n }\n return a[1] > b[1];\n }\n };\n\npublic:\n int mostBooked(int n, vector<vector<int>>& meeti...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n\n\n //Approach 2: sorting and using heapsort\n //Time complexity = O(M.log M + M.N)\n //Space complexity = O(N)\n int mostBooked(int n, vector<vector<int>>& meetings) {\n \n vector<long> meetingHeldCount(n, 0);\n \n auto compare = [](auto ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n\n\n //Approach 2: sorting and using heapsort\n //Time complexity = O(M.log M + M.N)\n //Space complexity = O(N)\n int mostBooked(int n, vector<vector<int>>& meetings) {\n \n vector<long> meetingHeldCount(n, 0);\n \n auto compare = [](auto ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<long long> arr(n,0);\n sort(meetings.begin(),meetings.end());\n priority_queue<vector<long long>,vector<vector<long long>>,greater<vector<long long>>> pq;\n priority_queue<vector<long ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<int> cnt(n);\n\n set<int> open;\n set<pair<long long, int>> freed;\n\n sort(meetings.begin(), meetings.end());\n for (int i = 0; i < n; ++i) {\n open.insert(i);\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n // Set of available rooms, sorted by room index\n set<int> available;\n for (int i = 0; i < n; i++) {\n available.insert(i);\n }\n\n // Set of busy rooms {end time, room ind...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "#define ll long long\nclass Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(),meetings.end());\n // for(auto &meeting:meetings)\n // meeting[1]--;\n set<pair<ll,ll>> dp;\n vector<ll> numHeld(n);\n set<ll> fr...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\nprivate:\n int n = 0;\n priority_queue<int, vector<int>, greater<int>> available;\n priority_queue<pair<long,long>, vector<pair<long,long>>, greater<pair<long,long>>> bookedRooms;\n vector<int> rooms;\n vector<vector<int>> meetings;\n\n void fillAvailableRoomsQueue(){\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& ar) {\n vector<int> co(n, 0);\n multiset<pair<long,int>> ms;\n for(int i=0;i<n;++i)\n ms.insert({-1, i});\n \n sort(ar.begin(), ar.end());\n for(int i=0;i<ar.size();++i)\n {...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& ar) {\n vector<int> co(n, 0);\n multiset<pair<long,int>> ms;\n for(int i=0;i<n;++i)\n ms.insert({-1, i});\n \n sort(ar.begin(), ar.end());\n for(int i=0;i<ar.size();++i)\n {...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, const vector<vector<int>>& meetings) {\n // Create sorted lists of start and end times of meetings\n vector<vector<int>> start;\n start.reserve(meetings.size());\n for (int i = 0; i < meetings.size(); ++i) {\n start...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n set<long long> free_rooms;\n for(long long i = 0;i<n;i++) {\n free_rooms.insert(i+1);\n }\n\n priority_queue<pair<long long,long long>, vector<pair<long long,long long>>, greater<p...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(),meetings.end());\n priority_queue<long long, vector<long long> , greater<long long>> freeRooms;\n\n for(int i=0;i<n;i++){\n freeRooms.push(i);\n }\n\n ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\n #define ll long long\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n vector<ll> meets(n,0);\n set<ll> s;\n for(int i=0;i<n;i++) s.insert(i);\n ll time = 0, ans = 0, mv = 0;\n priority_queue<vector<ll>, vector<vector<ll>>, great...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int n, vector<vector<int>>& meetings) {\n sort(meetings.begin(),meetings.end());\n priority_queue<pair<uint64_t,int>,vector<pair<uint64_t,int>>,greater<pair<uint64_t,int>>> pq;\n pair<uint64_t,int> p;\n set<int> s;\n uint64_t ...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int k, vector<vector<int>>& v) {\n sort(v.begin(),v.end());\n priority_queue<vector<long long int>,vector<vector<long long int>>,greater<vector<long long int>>> pq;\n set<long long int> st;\n for(int i=0;i<k;i++){\n st.ins...
2,479
<p>You are given an integer <code>n</code>. There are <code>n</code> rooms numbered from <code>0</code> to <code>n - 1</code>.</p> <p>You are given a 2D integer array <code>meetings</code> where <code>meetings[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means that a meeting will be held during the <strong>half-cl...
3
{ "code": "class Solution {\npublic:\n int mostBooked(int k, vector<vector<int>>& v) {\n sort(v.begin(),v.end());\n priority_queue<vector<long long int>,vector<vector<long long int>>,greater<vector<long long int>>> pq;\n set<long long int> st;\n for(int i=0;i<k;i++){\n st.ins...