id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n \n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> next(n);\n for(auto e : edges) {\n if(e[2] > distanceThreshold) continue;\n next[e[0]].push_back({e[2], e[1]});\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n // return city num\n int getCityNum(const vector<vector<std::pair<int,int>>>& graph, const int threshold, const int start) {\n const int n = graph.size();\n \n vector<bool> visited(n, false);\n int count = 0;\n\n // <distance, node>\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "//Burak Emre Polat\nclass Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> graph(n);\n for (auto v: edges) {\n graph[v[0]].push_back({v[1],v[2]});\n graph[v[1]].push_back({v[0],v[2]});\n... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "//Burak Emre Polat\nclass Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> graph(n);\n for (auto v: edges) {\n graph[v[0]].push_back({v[1],v[2]});\n graph[v[1]].push_back({v[0],v[2]});\n... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "#include <ranges>\n\nclass Solution {\npublic:\n int numCitiesWithinReach(int i) const {\n\n auto q = std::priority_queue<std::pair<int,int>, std::vector<std::pair<int,int>>, std::ranges::greater>{}; // {distance, node}\n auto dist = std::vector(mN, std::numeric_limits<int>::max());\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "#include <ranges>\n\nclass Solution {\npublic:\n int numCitiesWithinReach(int i) const {\n\n auto q = std::priority_queue<std::pair<int,int>, std::vector<std::pair<int,int>>, std::ranges::greater>{}; // {distance, node}\n auto dist = std::vector(mN, std::numeric_limits<int>::max());\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int k) {\n int count = 0;\n unordered_map<int,unordered_set<int>> map;\n for(int i = 0; i < n; i++){\n map[i] = {};\n }\n vector<vector<pair<int,int>>> graph(n);\n for(auto... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n vector<pair<int,int>>vec[102];\n int dist[102];\n\n\n int dijk(int src,int dt,int n)\n {\n dist[src]=0;\n pair<int,int> p;\n set<pair<int,int>>s;\n p.first=0;\n p.second=src;\n s.insert(p); \n\n while(!s.empty())\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n vector<pair<int,int>>vec[102];\n int dist[102];\n\n\n int dijk(int src,int dt,int n)\n {\n dist[src]=0;\n pair<int,int> p;\n set<pair<int,int>>s;\n p.first=0;\n p.second=src;\n s.insert(p); \n\n while(!s.empty())\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n void bfs(int start,vector<bool>&vis,int c,int dt,vector<pair<int,int>>adj[]){\n queue<pair<int,int>>q;\n q.push({start,0});\n while(!q.empty()){\n auto itr=q.front();\n q.pop();\n start=itr.first;\n vis[start]=true;\n fo... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "typedef pair<int, int> ppi;\n\nclass Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<int> dis(n, 1e9);\n set<ppi> s;\n vector<vector<ppi>> G(n);\n for (auto x : edges) {\n G[x[0]].push_back({x[1], x[2]});\n... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& v, int k) {\n\n // bruteforce\n\n vector<pair<int,int>> adj[n];\n\n for(auto vec : v)\n {\n adj[vec[0]].push_back({vec[1],vec[2]});\n adj[vec[1]].push_back({vec[0],vec[2]});\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n // cache the result\n unordered_map<int,vector<pair<int,int>>> graph;\n for (int i = 0; i<edges.size(); i++){\n int a = edges[i][0], b = edges[i][1], w = edges[i][2];... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n vector<int>dijkstra(vector<pair<int,int>>adj[],int src,int n){\n set<pair<int,int>>s;\n s.insert({0,src});\n vector<int>dist(n,1e9);\n dist[src]=0;\n \n while(!s.empty()){\n auto it = *(s.begin());\n int d = it.f... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n unordered_map<int,vector<pair<int,int>>>adj;\n for(auto i:edges){\n adj[i[0]].push_back({i[1],i[2]});\n adj[i[1]].push_back({i[0],i[2]});\n }\n set<... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int dijkstra(vector<vector<pair<int, int>>> &adj, int threshold, int src, int n) {\n multiset<pair<int, int>> min_heap;\n min_heap.insert({0, src});\n vector<int> dist(n, INT_MAX);\n dist[src] = 0;\n while(!min_heap.empty()) {\n p... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n\n int nodes ;\n int dijk(vector<vector<pair<int,int>>>& g , int thresh , int city){\n multiset<pair<int,int>> s;\n s.insert({0,city});\n vector<int> dis(nodes,INT_MAX);\n dis[city] = 0;\n while(!s.empty()){\n auto z = *s.begin(... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n vector<int> dijkstra(vector<pair<int, int>> graph[], int source, int n) {\n vector<int> distances(n, 1e9);\n distances[source] = 0;\n vector<int> visited(n, 0);\n set<pair<int, int>> s;\n s.insert({0, source});\n while (!s.empty()) {\... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\n private:\n int Solve(unordered_map<int,vector<pair<int,int>> >& adjList,int n,int node,int threshold)\n {\n set<pair<int,int> >st;\n vector<int>dist(n,INT_MAX);\n dist[node]=0;\n st.insert({0,node});\n while(!st.empty())\n {\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\n void buildGraph(vector<vector<int>>& edges,unordered_map<int,list<pair<int,int>>>& graph){\n for(int i=0;i<edges.size();i++){\n graph[edges[i][0]].push_back(make_pair(edges[i][1],edges[i][2]));\n graph[edges[i][1]].push_back(make_pair(edges[i][0],edges[i][... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int Dijkstra(int src, int n, unordered_map<int, list<pair<int, int>>>&adjList, int&distanceThreshold){\n vector<int> dist(n, INT_MAX);\n set<pair<int, int>> st;\n dist[src] = 0;\n st.insert({0, src});\n int reachableCities = 0; //cities havi... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n\n\n int Dijkstra(int src, int n, unordered_map<int,list<pair<int,int>>>&adjList, int&distanceThreshold){\n\n vector<int>dist(n,INT_MAX);\n set<pair<int,int>>st;\n dist[src]=0;\n st.insert({0,src});\n int reachableCities=0;\n while(!st... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int djikstra(int src,int n,unordered_map<int,list<pair<int,int>>>&adjList,int distanceThreshold)\n {\n vector<int>dist(n,INT_MAX);\n dist[src]=0;\n\n set<pair<int,int>>st;\n st.insert({0,src});\n\n int reachableCities = 0;\n while(... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, std::vector<std::vector<int>>& edges, int distanceThreshold) {\n std::vector<std::vector<std::pair<int, int>>> nodes(n);\n for (std::vector<int> e : edges) {\n nodes[e[0]].push_back(std::pair<int,int>(e[1],e[2]));\n n... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n std::unordered_map<int, std::vector<std::pair<int, int>>> graf;\n for(int i = 0; i < n; ++i) {graf[i] = {};}\n create(graf, edges);\n int city = 0, max = n;\n for (auto it =... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n\n std::vector<std::vector<std::pair<int, int>>> nodes(n);\n for (auto& v : edges) {\n nodes[v[0]].push_back({v[1], v[2]});\n nodes[v[1]].push_back({v[0], v[2]});\... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\n int dijkstra(int &n, unordered_map<int,list<pair<int,int>>> &g, int &d, int i){\n vector<int> ans(n,INT_MAX);\n vector<bool> visit(n);\n ans[i] = 0;\n set<pair<int,int>> s;\n s.insert({0,i});\n while(!s.empty()){\n pair<int,int> p =... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n\n int noOfCitesCanVisit(vector<pair<int, int>> nodes[], int curr, int sz, int &dthres) {\n\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n\n pq.push({0, curr});\n int count = 0;\n bool vis[sz];\n memse... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n\n int noOfCitesCanVisit(vector<pair<int, int>> nodes[], int curr, int sz, int &dthres) {\n\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n\n pq.push({0, curr});\n int count = 0;\n bool vis[sz];\n memse... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n\n vector<vector<pair<int,int>>>v(n);\n for(int i=0;i<edges.size();i++)\n {\n v[edges[i][0]].push_back({edges[i][1],edges[i][2]});\n v[edges[i][1]].push_bac... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<int> citiesVis(n, 0);\n\n vector<pair<int, int>> adj[n];\n\n for(auto x : edges){\n adj[x[0]].push_back({x[1], x[2]});\n adj[x[1]].push_back({x[0], ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> graph(n);\n for (auto& edge : edges) {\n graph[edge[0]].push_back({edge[1], edge[2]});\n graph[edge[1]].push_back({edge[0], edge[2]... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int getMinReached(int i,int n, vector<pair<int,int>> *adj, int distanceThreshold) {\n if(distanceThreshold == 0) return 0;\n vector<int> visited(n,INT_MAX);\n priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q; // { dist covere... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findNumberOfNeighbor(int n, int i, vector<vector<pair<int, int>>>& adj, int distanceThreshold) {\n priority_queue<pair<int, int>> pq;\n int numberOfNeighbor = 0;\n vector<bool> visited(n, false);\n visited[i] = true;\n pq.push({0, i});\n... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n\n vector<pair<int, int>>adj[n];\n for(auto it : edges){\n int u = it[0],v = it[1], w = it[2];\n adj[u].push_back({v, w});\n adj[v].pu... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n \n // Since weight > 0, we can treat 0 as INF.\n std::vector<std::vector<int>> adjMatrix(n, std::vector<int>(n));\n for (const auto &v : edges){\n adjMatrix[v[... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "struct compare{\n bool operator()(pair<int,int>& a, pair<int,int>& b){\n return b.second<a.second;\n }\n};\nclass Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) { \n int res=0, cur=INT_MAX;\n vector<vector<pair<int,int>>> ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "//Mehmet Fuat Karakaya\n\nclass Solution {\npublic:\n int dijk(int node, int tresh, vector<vector<pair<int,int>>>& adj, int n, vector<bool> &visited){\n visited.assign(visited.size(), 0);\n priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n int count=... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int djistra(int src, int n, vector<vector<pair<int, int>>>& adjL, int distanceThreshold){\n vector<int> dist(n, -1);\n\n priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n\n pq.push({0, src});\n\n int num_vertices = ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findNumbNeighbor(int n, vector<vector<pair<int, int>>> &adj, int i, int distanceThreshold) {\n int ans = 0;\n vector<bool> visited(n, false);\n priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n pq.push({0, i});\... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "//Hilal Parlakçı\nclass Solution {\n vector<vector<pair<int,int>>> adj;\n int distance;\n int size;\nprivate:\n void dj(vector<int>& res, int target) {\n priority_queue<pair<int, int>, vector<pair<int, int>>,\n greater<pair<int, int>>> pq;\n vector<int> visited(size);\n\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "//Hilal Parlakçı\nclass Solution {\nprivate:\n vector<vector<pair<int,int>>> adj;\n int distance;\n int size;\n\n int dijkstra(int target) {\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n vector<int> visited(size);\n\n pq.push({0,tar... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\nstruct cmp{\n bool operator()(pair<int,int> a, pair<int,int> b){\n return a.first>b.first;\n }\n};\nint findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) \n{\n unordered_map<int,unordered_map<int,int>> mp;\n for(auto edge:edges){\n mp... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int, vector<pair<int, int>>> adj;\n \n int dijkstra(int src, int n, int dT){\n vector<int> visited(n, 0);\n priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n pq.push({0, src});\n\n while(!pq.e... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n\n int dijkstra(int src, int distanceThreshold, vector<vector<pair<int, int>>>& adj){\n\n unordered_set<int> visited(src);\n priority_queue<pair<int, int>> pq; pq.push({0, src});\n while(pq.size()){ \n auto [distance, node] = pq.top(); pq.p... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\n struct Edge {\n int to;\n int weight;\n };\n\n struct EdgeComparator {\n bool operator()(const Edge& e1, const Edge& e2) {\n return e1.weight > e2.weight;\n }\n };\n using Path = Edge;\npublic:\n int findTheCity(int n, vector<vecto... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\nprivate:\n int f(int node,int n,int tar,vector<pair<int,int>> adj[]){\n priority_queue<pair<int,int>, vector<pair<int,int>>, greater<>> pq;\n\n pq.push({0,node});\n set<int> st;\n vector<int> vis(n,0);\n vis[node]=1;\n while(!pq.empty()){\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int vis[101];\n int findTheCity(int n, vector<vector<int>>& x, int a) {\n ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);\n vector<vector<pair<int,int>>>v(n);\n vector<set<int>>s(101);\n for(int i=0;i<x.size();i++){\n ... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> adj(n, vector<pair<int, int>>());\n for (const auto& e : edges) {\n adj[e[0]].push_back({e[1], e[2]});\n adj[e[1]].push_back({e[0],... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n vector<vector<pair<int, int>>> adj(n, vector<pair<int, int>>());\n for (const auto& e : edges) {\n adj[e[0]].push_back({e[1], e[2]});\n adj[e[1]].push_back({e[0],... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "struct cmp {\n bool operator()(pair<int, int> &v1, pair<int, int> &v2) {\n return v1.second > v2.second;\n }\n};\n\nclass Solution {\npublic:\n void dijkstra(vector<vector<pair<int, int>>> &g, int start, int threshold, vector<vector<int>> &dists) {\n priority_queue<pair<int, int>, ve... |
1,456 | <p>There are <code>n</code> cities numbered from <code>0</code> to <code>n-1</code>. Given the array <code>edges</code> where <code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional and weighted edge between cities <code>from<sub>i</sub></code> and <code>to<sub>i</sub><... | 3 | {
"code": "class Solution {\npublic:\n int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {\n // first convert graph to adjacency list representation\n vector<vector<pair<int, int>>> graph(n); // i-th nodes will have graph[i] neighbors\n for (const auto& edge : edges) {\... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\n int dp[301][11];\n int solve(vector<int>& v,int i,int d){\n if(i==v.size()){\n if(d==0)return 0;\n else return 1e9;\n }\n if(d==0)return 1e9;\n if(dp[i][d]!=-1)return dp[i][d];\n int maxi=0;\n int ans=1e9;\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\n int dp[301][11];\n int solver(vector<int>& jd,int n,int idx,int d){\n if(d==1){\n int maxD = jd[idx];\n for(int i=idx;i<n;i++) maxD = max(maxD,jd[i]);\n\n return maxD;\n }\n if(dp[idx][d]!=-1) return dp[idx][d];\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\nint n;\nint t[301][11];\nint solve(vector<int>& jobDifficulty,int index,int d){\n if(d==1){\n int maxi=jobDifficulty[index];\n for(int i=index;i<n;i++){\n maxi=max(maxi,jobDifficulty[i]);\n }\n return maxi;\n }\n if(t[index][d]!=-1... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\nint n;\nint t[301][11];\nint solve(vector<int>& jobDifficulty,int index,int d){\n if(d==1){\n //int maxi=jobDifficulty[index];\n int maxi=*max_element(jobDifficulty.begin()+index,jobDifficulty.end());\n /*for(int i=index;i<n;i++){\n maxi=max(max... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n return minDifficultyVersion(jobDifficulty, d);\n }\n\n int minDifficultyVersion(const vector<int>& jobDifficulty, int d) {\n const int n = static_cast<int>(jobDifficulty.size());\n\n if (n < d... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 0 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n if( n<d) return -1;\n vector<int> prev(n + 1, 0);\n vector<int> curr(n + 1, 0);\n\n // base case\n prev[n] = 0; // index >= n && d == 1.\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n if(d > n) return -1;\n\n vector<vector<int>> dp(n, vector<int>(2, -1));\n dp[n - 1][1 % 2] = jobDifficulty[n - 1];\n\n for (int i = n - 2; i >= 0; i--) ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) \n {\n int jobs = jobDifficulty.size();\n\n if(jobs < d) return -1;\n if(jobs == d) return accumulate(jobDifficulty.begin(), jobDifficulty.end(), 0);\n\n int max_difficulty = *max_element(jobD... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\npublic:\n int solve(vector<int>&jd, int n, int idx, int d, vector<vector<int>>&t) {\n if (d == 1) {\n return *max_element(jd.begin() + idx, jd.end());\n }\n\n int maxD = INT_MIN;\n int finalRes = INT_MAX;\n\n if(t[idx][d] != -1) return t[id... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\npublic:\n int solve(int i, int d, int cur_max, vector<int>& jobDifficulty, vector<vector<int>>& memo) {\n // If all jobs are scheduled, return 0 if days are exhausted, else return infinity\n if (i == jobDifficulty.size()) return d == 0 ? 0 : INT_MAX;\n if (d == 0) ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "#define LL long long\n#define PQ priority_queue\n#define VI vector<int>\n#define VL vector<long>\n#define VUL vector<unsigned long>\n#define VVI vector<vector<int>>\n#define VVVI vector<vector<vector<int>>>\n#define VVL vector<vector<long>>\n#define VVUL vector<vector<unsigned long>>\n#define VVB vector<ve... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\n int solve(int idx, int n, int d, vector<int> &difficulty, vector<vector<int>> &dp) {\n if((n - idx) < d) return -1;\n \n if(dp[idx][d] != -1) return dp[idx][d];\n\n if(d == 1) {\n int temp = difficulty[idx];\n for(int i = idx; i < n; i... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 1 | {
"code": "class Solution {\npublic:\nint solve(vector<int>&jobDifficulty,int d,int idx,int n,vector<vector<int>>&dp)\n{\n if(d==1)\n {\n int maxD=jobDifficulty[idx];\n for(int i=idx;i<n;i++)\n {\n maxD=max(maxD,jobDifficulty[i]);\n }\n return maxD;\n }\nif(dp[id... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 2 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n \n // If we can't split jobs into exactly d days, return -1.\n if (d > n) return -1;\n \n // DP table: dp[i][cut] is the minimum difficulty to sc... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 2 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n if (n < d)\n return -1;\n\n vector < vector < int > > dp(n, vector < int > (d + 1, INT_MAX));\n\n dp[n - 1][d] = jobDifficulty[n - 1];\n\n fo... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\nprivate:\n long long getMinDifficulty(vector<int>&a,int ind,int d,int n,vector<vector<long long>>&dp){\n\n if(ind>n || d<0) return INT_MAX;\n if(ind==n){\n return d==0 ? 0 : INT_MAX;\n }\n if(dp[ind][d]!=-1) return dp[ind][d];\n\n long long... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\nprivate:\n long long getMinDifficulty(vector<int>&a,int ind,int d,int n,vector<vector<long long>>&dp){\n\n if(ind>n || d<0) return INT_MAX;\n if(ind==n){\n return d==0 ? 0 : INT_MAX;\n }\n if(dp[ind][d]!=-1) return dp[ind][d];\n\n long long... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\nprivate:\n long long getMinDifficulty(vector<int>&a,int ind,int d,int n,vector<vector<long long>>&dp){\n\n if(ind>n || d==0) return INT_MAX;\n if(ind==n){\n return d==1 ? 0 : INT_MAX;\n }\n if(dp[ind][d]!=-1) return dp[ind][d];\n\n long lon... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\nprivate:\n long long getMinDifficulty(vector<int>&a,int ind,int d,int n,vector<vector<long long>>&dp){\n\n if(ind>n || d==0) return INT_MAX;\n if(ind==n){\n return d==1 ? 0 : INT_MAX;\n }\n if(dp[ind][d]!=-1) return dp[ind][d];\n\n long lon... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\nint n;\nint solve(int ind,vector<int>& jobDifficulty, int d, vector<vector<int>> &dp){\n \n if(dp[ind][d]!=-1)return dp[ind][d];\n int result=INT_MAX,sum=0,maxi=0;\n \n if(d==1){\n int maxii=-1;\n for(int j=ind;j<n;j++)maxii=max(maxii,jobDifficulty[j]... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int solve(int ind, int days, vector<int> jd, int n,\n vector<vector<int>>& dp) {\n if (days == 1) {\n int maxi = jd[ind];\n for (int i = ind; i < n; i++)\n maxi = max(maxi, jd[i]);\n\n return maxi;\n }... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int solve(int ind, int days, vector<int> jd, int n,\n vector<vector<int>>& dp) {\n if (days == 1) {\n int maxi = jd[ind];\n for (int i = ind; i < n; i++)\n maxi = max(maxi, jd[i]);\n\n return maxi;\n }... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int solve(int index,vector<int>& jd, int d,vector<vector<int>> &dp){\n if(index>=jd.size()){\n return -1;\n }\n if(d==1){\n return *max_element(jd.begin()+index,jd.end());\n }\n\n if(dp[index][d]!=-1){\n retu... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int solve(int index,vector<int>& jd, int d,vector<vector<int>> &dp){\n if(dp[index][d]!=-1){\n return dp[index][d];\n }\n\n if(index>=jd.size()){\n return 1e9;\n }\n if(d==1){\n return *max_element(jd.begin()... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int dp[1001][301];\n int solverec(vector<int>& jobDifficulty, int d, int idx) {\n if (idx == jobDifficulty.size()) {\n if(d==0){\n return 0;\n }\n return INT_MAX;\n }\n if (d == 0) {\n return I... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n vector<int> j;\n int dp[301][1001];\n int solve(int start,int left)\n {\n if(j.size()==start&&left==0) return 0;\n if(j.size()==start||left==0||j.size()<start+left) return 1e9;\n if(dp[start][left]!=-1) return dp[start][left];\n int ans=1e... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class SGT_PU{\n // segement tree point update \n // like fenwick tree\n // this is for 0 based indexing so idx=0\npublic:\n vector<int> seg;\n SGT_PU(int n){\n seg.resize(4*n+1);\n }\n void build(int idx,int low,int high,vector<int> &arr){\n if(low==high){\n se... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int memo[301][11];\n memset(memo, -1, sizeof(memo));\n function<int(int, int)> dfs = [&](int index, int dd){\n if(index == jobDifficulty.size()){\n if(dd == 0) return 0;\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& job, int d) {\n int n=job.size();\n vector<vector<int>> dp(n,vector<int>(d+1,-1));\n if(n<d) return -1;\n\n function<int(int,int)> solve = [&](int curr, int day){\n //if(day>d) return ;\n if(day>... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n \n if (d > n)\n return -1;\n \n vector hardestRemaining(n, 0);\n hardestRemaining[n - 1] = jobDifficulty[n - 1];\n for (int i =... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n \n if (d > n)\n return -1;\n \n vector hardestRemaining(n, 0);\n hardestRemaining[n - 1] = jobDifficulty[n - 1];\n for (int i =... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n if (jobDifficulty.size() < d)\n return -1;\n\n map<pair<int,int>,int> memo;\n return md(jobDifficulty, d, 0, memo);\n }\n\n int md(vector<int>& jobDifficulty, int daysRemaining, int... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n if (jobDifficulty.size() < d)\n return -1;\n\n map<pair<int,int>,int> memo;\n return md(jobDifficulty, d, 0, memo);\n }\n\n int md(vector<int>& jobDifficulty, int daysRemaining, int... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int f(vector<int>& j, int d, int n, int idx,map<pair<int,int>,int>&dp) {\n if(dp.find({d,idx})!=dp.end())return dp.find({d,idx})->second;\n if(d==1){\n int t = j[idx];\n for(int i = idx; i<n; i++)t=max(t,j[i]);\n return t;\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int f(vector<int>& j, int d, int n, int idx,map<pair<int,int>,int>&dp) {\n if(dp.find({d,idx})!=dp.end())return dp.find({d,idx})->second;\n if(d==1){\n int t = j[idx];\n for(int i = idx; i<n; i++)t=max(t,j[i]);\n return t;\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int f(int i,int d,vector<int>&v,vector<vector<int>>&dp){\n int n=v.size();\n if(d==1){\n return *max_element(v.begin()+i,v.end());\n }\n if(dp[i][d]!=-1){\n return dp[i][d];\n }\n int maxi=INT_MIN;\n int a... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "#include<bits/stdc++.h>\nclass Solution {\n \npublic:\n // unordered_map<pair<int,int>,int>mp; cant use unodered map for a pair\n map<pair<int,int>,int>mp;\n int solve(int ind,int d,vector<int>& jobDifficulty){\n // ind and day changes but d is dynamic\n // base case\n int ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "#include<bits/stdc++.h>\nclass Solution {\n \npublic:\n // unordered_map<pair<int,int>,int>mp; cant use unodered map for a pair\n map<pair<int,int>,int>mp;\n int solve(int ind,int d,vector<int>& jobDifficulty){\n // ind and day changes but d is dynamic\n // base case\n int ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n size_t getKey(int a, int b) {\n return (size_t) a << 32 | (unsigned int) b;\n }\n\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n unordered_map<size_t, int> memo;\n\n int current = dfs(0, d, memo, jobDifficulty);\n return current =... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int helper(int i, int d,vector<int>& arr,map<pair<int,int>, int>& mp){\n int n = arr.size();\n if(i==n && d==0){\n return 0;\n }\n if((i<n && d==0) || (i>=n && d>0))return -1;\n if(mp.count({i,d}))return mp[{i,d}];\n int mx... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\nprivate:\n \n struct Key{\n int job;\n int day;\n \n Key(int j,int d):job(j),day(d) {}\n \n bool operator==(const Key& other) const{\n return job==other.job && day==other.day;\n }\n };\n \n struct KeyHash{\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n using State = pair<int, int>;\n int solve(std::map<State, int> & dp, State const & s, vector<int> & difficulty, int days) {\n \n if(dp.find(s) != dp.end()) \n return dp.at(s);\n \n int index;\n int day;\n std::tie(index,... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\n int memo[1000][1000];\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n if (n < d) {\n return -1;\n }\n\n // Initialize memo array with -1\n memset(memo, -1, sizeof(memo));\n\n re... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\n map<pair<int, int>, int> mp;\n int minDif(vector<int> &jobDifficulty, int d, int idx){\n if(mp.find({d, idx}) != mp.end()) return mp[{d, idx}];\n int n = jobDifficulty.size();\n if(d == 0) return mp[{d, idx}] = (idx == n) ? 0 : INT_MAX; \n if(idx == n) r... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n map<string,int>dp;\n\n int f(int lvl, int currD, int d, vector<int>&a, int n){\n if(currD==d){\n int lstMx=INT_MIN;\n for(int i=lvl;i<n;i++) lstMx=max(lstMx, a[i]);\n return lstMx;\n }\n\n string key = to_string(lvl)+\"... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n\n int solve(int cur, int day, vector<vector<int>> &dp, vector<int> &v, int n){\n if(day==0){\n if(cur>=n) return 0;\n return 1e9;\n }\n if(cur>=n){\n if(day>0) return 1e9;\n return 0;\n }\n if(dp[c... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<int>& job, int n, int index, int d, vector<vector<int>>& dp) {\n // base case\n if (d == 1) {\n int maxD = job[index];\n\n for (int i = index; i < n; i++) {\n maxD = max(maxD, job[i]);\n }\n ... |
1,457 | <p>You want to schedule a list of jobs in <code>d</code> days. Jobs are dependent (i.e To work on the <code>i<sup>th</sup></code> job, you have to finish all the jobs <code>j</code> where <code>0 <= j < i</code>).</p>
<p>You have to finish <strong>at least</strong> one task every day. The difficulty of a job sch... | 3 | {
"code": "class Solution {\npublic:\n int minDifficulty(vector<int>& jobDifficulty, int d) {\n int n = jobDifficulty.size();\n vector<int>arr(n+1);\n for(int i = 1; i<=n; i++){\n arr[i] = jobDifficulty[i-1];\n }\n vector<vector<int>>mx(n+1,vector<int>(n+1));\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.