id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n ios_base :: sync_with_stdio(false);\n cin.tie(nullptr);cout.tie(nullptr);\n int ans = 0;\n int start_x = -2;\n vector<int> dau_x(points.size());\n for (int i=0;i<p... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n\n\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n = points.size();\n vector<int> xs(n);\n for (int i=0; i<n; i++) xs[i] = points[i][0];\n sort(xs.begin(), xs.end());\n\n int r = 0;\n int right = -1;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nclass Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n=points.size();\n vector<int> x(n,-1);\n for(int i=0; i<n; i++) x[i]=points[i][0];\n sort(x.begin(), x.end());\n int ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nclass Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n=points.size();\n vector<int> x(n,-1);\n for(int i=0; i<n; i++) x[i]=points[i][0];\n sort(x.begin(), x.end());\n int ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int ans = 0; \n int n = points.size(); \n vector<int> x(n, 0);\n for(int i=0; i<n; i++) x[i] = points[i][0];\n sort(x.begin(), x.end());\n\n int xx = -1; \n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n=points.size();\n vector<int> x(n,-1);\n for(int i=0; i<n; i++) x[i]=points[i][0];\n sort(x.begin(), x.end());\n int ans=0, k=0;\n while(k<n){\n k=... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int lst=-1;\n int n=points.size();\n vector <pair<int,int>> a(n);\n for(int i=0;i<n;i++)\n {\n a[i].first=points[i][0];\n a[i].second=points[i][1];\... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n\n int n=points.size();\n\n vector<int> v;\n\n for(int i=0;i<n;i++)\n {\n v.push_back(points[i][0]);\n }\n \n sort(v.begin(),v.end());\n\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int>x;\n for(int i=0;i<points.size();i++){\n x.push_back(points[i][0]);\n }\n sort(x.begin(),x.end());\n int cnt = 1;\n long long dis = x[0]; // Start... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int>v;\n for(int i=0;i<points.size();i++)\n {\n v.push_back(points[i][0]);\n }\n sort(v.begin(),v.end());\n int c=0;\n int i=0,j=0;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int>xcor;\n\n for (int i=0;i<points.size();i++){\n xcor.push_back(points[i][0]);\n }\n\n sort(xcor.begin() , xcor.end());\n\n int cnt = 0;\n int ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n=points.size();\n\n vector<int> x;\n\n for (int i = 0; i < n; i++)\n {\n x.push_back(points[i][0]);\n }\n \n sort(x.begin(),x.end());\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n\n sort(points.begin(),points.end());\n\n vector<int> x;\n int count = 0;\n for(int i=0;i<points.size();i++){\n x.push_back(points[i][0]);\n }\n\n for(in... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\n public:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int ans = 0;\n int prevX = -w - 1;\n vector<int> xs;\n\n for (const vector<int>& point : points) {\n const int x = point[0];\n xs.push_back(x);\n }\n\n ranges::sort(xs);\n\n f... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n \n vector<long long>x;\n for(int i=0;i<points.size();i++){\n x.push_back(points[i][0]);\n }\n sort(x.begin() ,x.end());\n int b=INT_MIN;\n int ans=0;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;\n\n for(int i = 0;i<points.size();i++){\n pq.push({points[i][0],points[i][1]});\n }\n\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int n = points.size();\n if (n == 0) return 0; // No points, no rectangles needed\n \n // Priority queue to sort points by their x-coordinate\n priority_queue<pair<int,in... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n \n int search(vector<vector<int>>& points, int l, int xMax){\n int n=points.size();\n \n int r = n-1;\n while(l<r){\n int m = l+(r-l)/2;\n \n if(points[m][0] > xMax){\n r=m;\n }else{\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n // int n = points.size();\n // map<int,int>map; // x-coordinates\n // for(int i=0;i<n;i++){\n // map[points[i][0]]++;\n // }\n // vector<int>ranges;\n /... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(), points.end());\n int res = 1, cur = points[0][0];\n for(auto point: points) {\n if(point[0] > cur + w) {\n cur = point[0];\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(),points.end());\n int ans=0;\n int last=-1;\n for(auto x:points)\n {\n if(x[0]>last)\n {\n last=x[0]+w;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(),points.end());\n int ans=1,st=points[0][0];\n for(auto point:points) {\n int x = point[0];\n if(x-st>w) {\n // cout<<st<<endl;\... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(), points.end());\n int cnt = 1;\n int start = points[0][0];\n for(auto it: points){\n if(it[0] > start + w) {\n cnt++;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(),points.end());\n stack<int> st;\n int ans = 0;\n int prev= -1;\n for(auto it:points){\n if(prev==-1 or (prev!=it[0] and it[0]-prev>w)){\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& a, int w) {\n int n =a.size();\n vector<int>x(n);\n int i=0;\n for(auto it:a){\n x[i]= a[i][0];\n i++;\n }\n sort(x.begin(),x.end());\n int cnt=1;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "#include <algorithm>\n#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nclass Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int> x_cords;\n x_cords.reserve(points.size());\n\n for (auto point : points) {\n x_cords.push_back(poin... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "#include <algorithm>\n#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nclass Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int> x_cords;\n x_cords.reserve(points.size());\n\n for (auto point : points) {\n x_cords.push_back(poin... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& p, int w) \n {\n map<int,int>m;\n for(auto &x:p)\n {\n m[x[0]]=x[1];\n }\n int first=(m.begin()->first),count=0;\n for(auto it=m.begin();it!=m.end();it++)\n {\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& p, int w) \n {\n map<int,int>m;\n for(auto &x:p)\n {\n m[x[0]]=x[1];\n }\n int first=(m.begin()->first),count=0;\n for(auto it=m.begin();it!=m.end();it++)\n {\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n std::ios_base::sync_with_stdio(false);\n std::cout.tie(nullptr);\n std::cin.tie(nullptr);\n unordered_set<int> distinctx;\n for(int i=0;i<points.size();i++)\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 2 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n map<int,int> m;\n for(auto & point : points){\n m[point[0]]++;\n }\n int k = -1;\n int ans = 0;\n for(auto & val : m){\n if(val.first > k){\n... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>> &points, int w) {\n unordered_set<int> st;\n for (const auto &i: points) {\n st.insert(i[0]);\n }\n\n vector<int> storage(st.begin(), st.end());\n std::sort(storage.begin(), stora... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> s;\n for (auto &p : points) {\n s.insert(p[0]);\n }\n int right = -1, ans = 0;\n for (int e : s) {\n if (right < e) {\n righ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> xs;\n for (auto& point : points)\n xs.insert(point[0]);\n\n int start = -1e9 - 100, ans = 0;\n for (int x : xs) {\n if (x - start > w) {\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n sort(points.begin(),points.end());\n\n priority_queue<int,vector<int>,greater<int>>pq;\n\n for(auto it:points) pq.push(it[0]); int ans=0; int wt=-1;\n\n while(!pq.empty()){\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n \n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int ans=0,n=points.size();\n vector<int>v;\n for(auto x:points)\n {\n v.push_back(x[0]);\n }\n sort(v.begin(),v.end());\n for(int i=0;i<n;i... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int> xs;\n for(auto p : points) \n xs.push_back(p[0]);\n sort(xs.begin(), xs.end());\n\n int ans = 0;\n int last = - w - 2;\n for(int i = 0; i ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int>a ;\n int count = 1;\n for(auto x:points){\n a.push_back(x[0]);\n }\n sort(a.begin(),a.end());\n for(auto i:a) cout<<i;\n int start=a[... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n priority_queue<int, vector<int>, greater<int>> minHeap;\n for (auto p : points)\n {\n minHeap.push(p[0]);\n }\n\n int prev = -1;\n int res = 0;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> s;\n for (auto& i : points) {\n s.insert(i[0]); \n }\n vector<int> sorted_points(s.begin(), s.end()); \n sort(sorted_points.begin(), sorted_points.e... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> pset;\n int n = points.size(), i, res = 1, curr;\n for(i = 0; i < n; i++) pset.insert(points[i][0]);\n vector<int> pvec(pset.begin(), pset.end());\n n = pvec.si... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> se;\n for (int i = 0; i < points.size(); i++) {\n se.insert(points[i][0]);\n }\n vector<int> a(se.begin(), se.end());\n sort(a.begin(), a.end());\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n unordered_set<int>st;\n for(int i=0;i<points.size();i++)\n {\n st.insert(points[i][0]);\n }\n vector<int>v;\n int count = 0;\n for(auto it:st)\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> s1;\n int point=points.size();\n for (int i=0;i<point;i++) {\n s1.insert(points[i][0]);\n }\n vector<int> v1;\n for (auto i:s1) v1.push_back(i)... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> s1;\n\n for (int i=0;i<points.size();i++) {\n s1.insert(points[i][0]);\n }\n vector<int> v1;\n for (auto i:s1) v1.push_back(i);\n \n int... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<int> x;\n map<int,int> mp;\n for(int i=0;i<points.size();i++){\n if(!(mp[points[i][0]]>0))\n x.push_back(points[i][0]);\n mp[points[i][0]]++;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<pair<int,int>> v;\n\n for(auto it:points){\n\n v.push_back({it[0],it[1]});\n\n }\n\n sort(v.begin(),v.end());\n\n int ans=1;\n int a=83738,b=8487... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n vector<pair<int, int>>vp;\n\n for(auto it: points){\n vp.push_back({it[0], it[1]});\n }\n\n sort(vp.begin(), vp.end());\n\n\n // for(auto it: vp){\n // ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n int ans=0;\n vector<vector<int>>dummy;\n dummy=points;\n sort(dummy.begin(),dummy.end());\n for(int i=0;i<dummy.size();){\n int ele = dummy[i][0];\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n using ll = long long;\n vector<pair<ll, ll>> arr;\n int n = points.size();\n\n for (auto it : points) {\n arr.push_back({it[0]*1ll, it[1]*1ll});\n }\n\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "const static auto fast = [] {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\nclass Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\\\n set<int> xpoints;\n for(auto p : points) xpoints.... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> setX;\n for (auto point : points) {\n setX.insert(point[0]);\n }\n int count = 0;\n while (!setX.empty()) {\n int x = *setX.begin();\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> setX;\n for (auto point : points) {\n setX.insert(point[0]);\n }\n int count = 0;\n while (!setX.empty()) {\n int x = *setX.begin();\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n \n set <int> s;\n\n for(auto it: points){\n s.insert(it[0]);\n }\n\n int prev=-1;\n\n int count=0;\n\n for(auto it: s){\n // cout<<pre... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n \n \n map<int,int> mp;\n \n for(auto point : points) {\n mp[point[0]]++;\n }\n \n auto it = mp.begin();\n int prev = it->first;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\n /* int max_on_X(vector<vector<int>>& nums){\n int ans = 0;\n for(auto X : nums){\n ans = max(ans , X[0]);\n }\n return ans;\n } */\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>&po, int w) {\n /* int ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n unordered_set<int>s;\n for(auto x: points){\n s.insert(x[0]);\n }\n vector<int>k(s.begin(),s.end());\n sort(k.begin(),k.end());\n int ans = 0;\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n set<int> s;\n for(auto p:points){\n s.insert(p[0]);\n }\n int ans=0;\n vector<int> v (s.begin(),s.end());\n int left=0;\n int right=left+1;\n\n ... |
3,390 | <p>You are given a 2D integer array <code>points</code>, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. You are also given an integer <code>w</code>. Your task is to <strong>cover</strong> <strong>all</strong> the given points with rectangles.</p>
<p>Each rectangle has its lower end at some point <code... | 3 | {
"code": "class Solution {\npublic:\n int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n unordered_map<int,int>mp;\n for(auto it : points){\n mp[it[0]]++;\n }\n vector<int>temp;\n for(auto it : mp){\n temp.push_back(it.first);\n }... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n typedef pair<int,int> pr;\n void bfs(int start,vector<pair<int,int>>adj[],vector<int>&distance,vector<int>&disappear,int n) {\n priority_queue<pr,vector<pr>,greater<pr>>pq;\n pq.push({0,start});\n\n distance[start]=0;\n while(!pq.empty()) {\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n typedef pair<int,int> pr;\n void bfs(int start,vector<pair<int,int>>adj[],vector<int>&distance,vector<int>&disappear,int n) {\n priority_queue<pr,vector<pr>,greater<pr>>pq;\n pq.push({0,start});\n\n distance[start]=0;\n while(!pq.empty()) {\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "using P2I = pair<int, int>;\nclass Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<P2I> g[n];\n for(auto& edge: edges){\n int x = edge[0];\n int y = edge[1];\n int cost = edge[2];\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int,int>> adj[n];\n for(int i=0;i<edges.size();i++){\n adj[edges[i][0]].push_back({edges[i][1],edges[i][2]});\n adj[edges[i][1]].push_back({e... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<vector<pair<int,int>>>adj(n);\n for(int i=0;i<edges.size();i++){\n int u=edges[i][0];\n int v=edges[i][1];\n int wt=edges[i][2];\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n std::vector<std::vector<std::pair<int, int>>> adjs(n);\n for (auto& edge : edges) {\n auto u = edge[0];\n auto v = edge[1];\n auto w = edge[2]... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "// Time: O((|E| + |V|) * log|V|) = O(|E| * log|V|) by using binary heap,\n// if we can further to use Fibonacci heap, it would be O(|E| + |V| * log|V|)\n// Space: O(|E| + |V|) = O(|E|)\n\n// dijkstra's algorithm\nclass Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edg... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<int> dist(n, INT_MAX);\n dist[0] = 0;\n\n vector<vector<pair<int,int>>> adj_list(n);\n \n for(int i=0; i<edges.size(); i++) {\n adj_list... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges,\n vector<int>& disappear) {\n vector<vector<pair<int, int>>> g(n);\n\n for (auto& it : edges) {\n int u = it[0], v = it[1], wt = it[2];\n g[u].emplace_bac... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "/*\nclass Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<vector<pair<int, int>>> graph(n);\n for(int i = 0; i < edges.size(); i++){\n int first = edges[i][0];\n int second = edges[i][1];\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<int> ans(n, INT_MAX);\n vector<pair<int, int>> graph[n];\n for (auto& e : edges) {\n graph[e[0]].push_back({e[1], e[2]});\n graph[e[1]].pus... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n\n void dfs(int node, vector<int>&vis, vector<int> &dis,vector<vector<pair<int,int>>> &adj,vector<int>& disappear){\n\n for(int i=0;i<adj[node].size();i++){\n int next_node = adj[node][i].first;\n int new_dis = dis[node] + adj[node][i].second;\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int,int>>ed[n+1];\n for(int i = 0 ; i < edges.size(); i++){\n ed[edges[i][0]].push_back({edges[i][1],edges[i][2]});\n ed[edges[i][1]].push_ba... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<int>dist(n, INT_MAX);\n vector<pair<int, int>>adj[n];\n for(int i=0;i<edges.size();i+=1){\n adj[edges[i][0]].push_back({edges[i][1], edges[i][2]});\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n static bool cmp(vector<int>& a,vector<int>& b)\n {\n return a[2]<b[2];\n }\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<int> ans(n,1e9);\n ans[0]=0;\n vector<vector<pair<int,int>>> v(n);\n... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "//vector<int> dist(50002 + 2, INT_MAX);\nint dist[50002];\n\nvoid bfs(int i, int n, vector<vector<pair<int, pair<int, int>>>>& g) {\n\tpriority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;\n\tq.push({ 0, i }); // dist, vert\n\tdist[i] = 0;\n vector<bool> vis(n + 1, 0);\n\twh... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& a , vector<int>& dis) {\n vector<int> d(n,INT_MAX);\n vector<vector<pair<int,int>>> adj(n);\n \n for(auto& x:a)\n {\n adj[x[0]].push_back({x[1],x[2]});\n adj[x[1]].push_back({x[0]... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n #define P pair<int,int>\n\n vector<int> findResultCity(int n, vector<int>& SPM, vector<int>& disappear) {\n vector<int> result(n, -1);\n for (int i = 0; i < n; i++) {\n if (SPM[i] < disappear[i]) {\n result[i] = SPM[i];\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<long long>d(n,INT_MAX);\n vector<int>ans;\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;\n q.push({0,0});\n d[0]=0;... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "#define pp pair<int,int>\n#define ll long long\nclass Solution {\npublic:\n vector<int>vis; vector<vector<ll>>info; vector<int>dis;\n priority_queue<pp,vector<pp>,greater<pp>>pq;\n void djisktra(vector<vector<pp>>&graph,int src)\n {\n pq.push({0,0}); info[0][0] = info[0][1] = 0;\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 0 | {
"code": "#include <unordered_map>\n#include <queue>\n\nstruct Solution {\n using pr = pair<int, int>;\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<int> res(n, -1);\n unordered_map<int, vector<pr>> edgeList;\n for (auto &e : edges){\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int, int>> adj[n];\n for(auto e: edges)\n {\n adj[e[0]].push_back({e[1], e[2]});\n adj[e[1]].push_back({e[0], e[2]});\n }\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n\n vector<vector<pair<int, int>>> adjlist(n);\n\n for (auto& vec : edges)\n {\n int u = vec[0];\n int v = vec[1];\n int w = vec[2];\n\n adjlist[u].emplac... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int, int>>adj[n];\n for(auto it: edges){\n adj[it[0]].push_back({it[1], it[2]});\n adj[it[1]].push_back({it[0], it[2]});\n }\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n unordered_map<int, vector<pair<int, int>>> graph;\n for (const auto& edge : edges) {\n int u = edge[0], v = edge[1], length = edge[2];\n graph[u].push_back({v, length});... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<vector<pair<int,int>>>adj(n);\n for(auto edge:edges)\n {\n int u=edge[0];\n int v=edge[1];\n int len=edge[2];\n adj[u... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<vector<pair<int, int>>>adj(n);\n for(auto it:edges){\n int a=it[0];\n int b=it[1];\n int wt=it[2];\n adj[a].push_back({b, wt... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<vector<pair<int, int>>> adj(n); // adj[i] = {length, next}\n for (auto edge: edges) {\n int u = edge[0], v = edge[1], length = edge[2];\n adj[u].p... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n \n vector<int> v;\n \n void dfs(int s, vector<vector<pair<int, int>>> &adj, vector<int> &dis)\n {\n for(auto x: adj[s])\n {\n if((long)v[s]+x.second<dis[x.first] && (long)v[s]+x.second<v[x.first])\n {\n v[x.first]... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "#pragma GCC optimize(\"03\")\nclass Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int, int>> adj[50000];\n\n int szEdges = edges.size();\n {\n int cnt[50000] = {0};\n for (int i = 0; i <... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int, int>> adj[50000];\n\n int szEdges = edges.size();\n {\n int cnt[50000] = {0};\n for (int i = 0; i < szEdges; i++)\n {\... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int,int>> adj[n];\n \n for(auto it:edges){\n adj[it[0]].push_back({it[1],it[2]});\n adj[it[1]].push_back({it[0],it[2]});\n }\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& dis) {\n vector<int> dist(n,1e9);\n vector<pair<int,int>> adj[n];\n for(auto x:edges){\n adj[x[0]].push_back({x[1],x[2]});\n adj[x[1]].push_back({x[0],x[2]});\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n vector<pair<int,int>> adj[n];\n for(auto it:edges)\n {\n int u=it[0], v=it[1], wt=it[2];\n adj[u].push_back({v,wt});\n adj[v].push_back... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges,\n vector<int>& disappear) {\n vector<pair<int, int>> g[n];\n\n for (auto it : edges) {\n\n int u = it[0], v = it[1], wt = it[2];\n\n g[u].push_back({v, wt... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> minpq;\n minpq.push({0, 0});\n vector<vector<pair<int, int>>> pmap(n);\n for ( au... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> minpq;\n minpq.push({0, 0});\n vector<vector<pair<int, int>>> pmap(n);\n for ( au... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n // let's get minimum time to reach the source node 0\n // make graph(undirected)\n unordered_map<int, vector<pair<int, int>>> graph;\n\n for(auto edge : edges){\... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n unordered_map<int, vector<pair<int, int>> > adj;\n for(auto x:edges){\n adj[x[0]].push_back({x[1], x[2]});\n adj[x[1]].push_back({x[0], x[2]});\n ... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n unordered_map<int, vector<pair<int, int>>> adjlist;\n for (auto edge: edges)\n {\n adjlist[edge[0]].push_back({edge[1], edge[2]});\n adjlist[edge[... |
3,389 | <p>There is an undirected graph of <code>n</code> nodes. You are given a 2D array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, length<sub>i</sub>]</code> describes an edge between node <code>u<sub>i</sub></code> and node <code>v<sub>i</sub></code> with a traversal time of <code>length<sub>i... | 1 | {
"code": "class Solution {\npublic:\n vector<int> minimumTime(int n, vector<vector<int>>& edges, vector<int>& disappear) {\n // apply dijkstra's algo\n vector<int>dist(n,1e9);\n unordered_map<int,vector<pair<int,int>>>adj;\n for(auto it:edges){\n adj[it[0]].push_back({it[1],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.