id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
1
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
1
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
1
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\n# define opt() ios::sync_wi...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
1
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
1
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\n\nclass Solution {\npublic:...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,299
<p>You are given the <code>head</code> of a linked list, which contains a series of integers <strong>separated</strong> by <code>0</code>&#39;s. The <strong>beginning</strong> and <strong>end</strong> of the linked list will have <code>Node.val == 0</code>.</p> <p>For <strong>every </strong>two consecutive <code>0</co...
3
{ "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool check(vector<int> &time, int totalTrips, long long mid) {\n long long count = 0;\n for (int i=0; i<time.size();i++) {\n count += (long long)(mid/time[i]);\n }\n return count >= totalTrips;\n }\n long long minimumTime(vector<in...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n\n\n// Helper function to check if we can achieve the required totalTrips in a given time T\nbool canCompleteTrips(const vector<int>& time, long long T, long long totalTrips) {\n long long trips = 0;\n for (int t : time) {\n trips += T / t; // Number of trips each b...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool help(long long mid, const std::vector<int>& time, int totalTrips) {\n long long c = 0;\n for (auto x : time) {\n c += (mid / x);\n }\n return c >= totalTrips;\n }\n\n long long minimumTime(std::vector<int>& time, int totalTrip...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool isValid(vector<int>& time, int totalTrips, long long curTime) {\n long long curTrips = 0;\n for (int j = 0; j < time.size(); j++)\n curTrips += curTime / time[j];\n return curTrips >= totalTrips;\n }\n\n long long minimumTime(vector<...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool possible(vector<int>& time, long long givenTime, int totalTrips) {\n long long actualTrips = 0;\n \n for(int &t : time) {\n actualTrips += givenTime/t;\n }\n \n return actualTrips >= totalTrips;\n }\n \n long ...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool possible(vector<int>& time, long long givenTime, int totalTrips) {\n long long actualTrips = 0;\n \n for(int &t : time) {\n actualTrips += givenTime/t;\n }\n \n return actualTrips >= totalTrips;\n }\n \n long ...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool possible(vector<int>& time, long long givenTime, int totalTrips) {\n long long actualTrips = 0;\n \n for(int &t : time) {\n actualTrips += givenTime/t;\n }\n \n return actualTrips >= totalTrips;\n }\n \n long ...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
0
{ "code": "class Solution {\npublic:\n bool possible(vector<int>& time, long long givenTime, int totalTrips) {\n long long actualTrips = 0;\n \n for(int &t : time) {\n actualTrips += givenTime/t;\n }\n \n return actualTrips >= totalTrips;\n }\n \n long ...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
2
{ "code": "class Solution {\npublic:\nbool f(long long mid,vector<int>& time, int T){\n long long cnt = 0;\n for(auto it: time){\n cnt += mid/it;\n }\n return cnt >= T;\n}\n long long minimumTime(vector<int>& time, int totalTrips) {\n long long low = 1;\n long long high = 1000...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
2
{ "code": "class Solution {\npublic:\n bool check(long long mid,vector<int>& time, int totalTrips){\n long long trips=0;\n int n=time.size();\n for(int i=0;i<n;i++){\n trips+=mid/(long long)time[i];\n }\n if(trips<(long long)totalTrips) return false;\n else retu...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
3
{ "code": "class Solution {\npublic:\n bool check(long long mid,vector<int>& time, long long totalTrips){\n long long my_trip = 0;\n for(int i=0; i<time.size(); i++){\n my_trip += mid/time[i];\n }\n if(my_trip<totalTrips) return false;\n else return true;\n }\n l...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
3
{ "code": "class Solution {\nprivate:\n bool pred(long long t , vector<int>&time , int totalTrips){\n long long cnt = 0;\n for(int i = 0 ; i<time.size() ; i++){\n if(time[i]<=t){\n cnt += t/time[i]*1LL;\n }\n }\n return cnt>=totalTrips;\n }\npubli...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
3
{ "code": "class Solution {\n\n bool is_pos(vector<int>& times, long long mid, int totalTrips) {\n long long cnt = 0;\n for (auto & it : times) {\n cnt += (mid/it);\n if(cnt>=1LL*totalTrips){\n // cout<<mid<<\" \"<<cnt<<endl;\n return true;\n ...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
3
{ "code": "class Solution {\n\n bool check (vector<int>& time, int tt, long long t){\n\n long long cnt = 0;\n int n = time.size();\n for (int i = 0; i < n; i++){\n cnt += t / time[i];\n if (cnt >= tt) return true;\n }\n\n return cnt >= tt;\n }\n\npublic:\...
2,294
<p>You are given an array <code>time</code> where <code>time[i]</code> denotes the time taken by the <code>i<sup>th</sup></code> bus to complete <strong>one trip</strong>.</p> <p>Each bus can make multiple trips <strong>successively</strong>; that is, the next trip can start <strong>immediately after</strong> completi...
3
{ "code": "#define ll long long \n\nclass Solution {\npublic:\n ll total;\n bool check(ll x,vector<int>& time){\n ll count=0;\n for(auto i:time){\n count+=x/i;\n }\n return count>=total;\n }\n long long minimumTime(vector<int>& time, int totalTrips) {\n sort(t...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n \n\n int result = 0;\n\n int totaltime = 0;\n\n for( int i=0; i<n; i++ ){\n\n int temp = manager[i];\n\n\n while( temp != -1 ){\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n int ans=0;\n\n for(int i=0; i<n; i++){\n int node=i;\n int sum=0;\n\n while(manager[node]!=-1){\n sum+=informTime[manager[nod...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& managers, vector<int>& informTime) {\n vector<bool> visited(n, false);\n int max_time_to_inform_all_employees = 0;\n for(int i = 0; i < informTime.size(); ++i) {\n if(informTime[i] == 0) {\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& managers, vector<int>& informTime) {\n vector<bool> visited(n, false);\n int max_time_to_inform_all_employees = 0;\n for(int i = 0; i < informTime.size(); ++i) {\n if(informTime[i] == 0 && manage...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int recursiveSolver(int i, int headID, vector<int>& manager, vector<int>& informTime, vector<int>& dp){\n if(dp[i]!=-1){\n return dp[i];\n }\n if(i==headID){\n return dp[i]=informTime[i];\n }\n return dp[i]=recursiveSol...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n std::vector<int> dp;\n int calc(vector<int>& manager, vector<int>& informTime, int idx){\n if (dp[idx]!=-1)\n return dp[idx];\n \n dp[idx] = informTime[idx] + calc(manager, informTime, manager[idx]);\n return dp[idx];\n }\n\n\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> delay(n, -1);\n\n std::function<int(int)> l = [&](int emp) {\n if (0 > emp) {\n return 0;\n }\n int& d = delay[emp]...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> dp(n,0);\n vector<int> vis(n,0);\n int ans=0;\n for(int i=0;i<n;i++){\n int node=i;\n int sum=0;\n while(manager[nod...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n queue<int> q;\n vector<int> time(n, 0);\n vector<int> senior(n, 0);\n\n for(auto i : manager){\n if(i == -1) continue;\n senior[i]++;\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n queue<int> q;\n vector<int> time(n, 0);\n vector<int> senior(n, 0);\n\n for(auto i : manager){\n if(i == -1) continue;\n senior[i]++;\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\nvector<int>adj[100005];\nint dfs(int headID,vector<int>&informTime){\n int ans=0;\n for(auto it:adj[headID]){\n ans=max(ans,dfs(it,informTime));\n }\n return informTime[headID]+ans;\n\n}\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int solve(int start,vector<int>adj[],vector<int>&informTime){\n int ans = 0;\n for(int it:adj[start]){\n int res = informTime[start]+solve(it,adj,informTime);\n ans = max(res,ans);\n }\n return ans;\n }\n int numOfMinute...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int maxTime = INT_MIN;\n \n void DFS(vector<int> adjList[], vector<int>& informTime, int curr, int time) {\n // Maximum time for an employee to get the news.\n maxTime = max(maxTime, time);\n \n for (int adjacent : adjList[curr]) { \n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n const static int N = 1e5+2;\n vector<int> g[N];\n int depth[N];\n void dfs(int u,vector<int>& inf){\n for(auto v:g[u]){\n depth[v]=depth[u]+inf[u];\n dfs(v,inf);\n }\n }\n int numOfMinutes(int n, int r, vector<int>& manager, ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n \n int time = 0;\n int dfs(int u, vector<pair<int, int>> adj[], int parent){\n \n \n int ans = 0;\n for(auto &[v, time] : adj[u]){\n if(v != parent){\n ans = max(ans, time + dfs(v, adj, u));\n }\n }\...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int max_time = INT_MIN;\n void DFS(vector<pair<int, int>> adj[], int curr, int curr_time){\n max_time = max(max_time, curr_time);\n for(auto itr = adj[curr].begin(); itr != adj[curr].end(); itr++){\n DFS(adj, (*itr).first, curr_time + (*itr).second...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n void sumTime(int node, int time, int &ans, vector<pair<int,int>> mgT[]){\n if(mgT[node].size()==0) ans = max(time, ans);\n for(auto child: mgT[node]){\n sumTime(child.first, time+child.second, ans, mgT);\n }\n }\n\n int numOfMinutes(int n...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "vector<int> vis(100001, 0);\nint mx = 0;\nclass Solution {\npublic:\n int numOfMinutes(int n, int hid, vector<int>& manager, vector<int>& informTime) {\n vector<int> adj[n];\n int time[n];\n memset(time, 0, sizeof(time));\n mx = 0;\n for (int i = 0; i < n; i++)\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n \n int minutes = -1;\n int src = -1;\n for(int i=0;i<manager.size();i++)\n {\n if(manager[i] == -1)\n {\n src = i;\n...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\nvoid dfs(int node, vector<int> adj[], vector<int> &dp, vector<int>& informTime){\n for(auto it: adj[node]){\n dfs(it, adj, dp, informTime);\n dp[node] = max(informTime[node] + dp[it], dp[node]);\n }\n}\n int numOfMinutes(int n, int headID, vector<int>& mana...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int search(vector<int> adj[], vector<int>& informTime, int start, int n, vector<int>& mem)\n {\n if (mem[start] != -1)\n {\n return mem[start];\n }\n\n int t = -1;\n for (int e : adj[start])\n {\n t = max(t, s...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int dfs(vector<int> adj[], int root, vector<int> &dp, vector<int> &informTime){\n if(dp[root]!=-1) return dp[root];\n //cout<<root<<endl;\n int ans = -1;\n for(auto next:adj[root]){\n ans = max(ans, dfs(adj, next, dp, informTime));\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n \n int dfs(int id,vector<int>&vis,vector<int>ad[],vector<int>&it)\n {\n vis[id]=1;\n int mx=0;\n\n for(auto k : ad[id]){\n if(!vis[k]){\n mx= max(mx,dfs(k,vis,ad,it));\n }\n }\n\n return it[id]+mx;\...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\nvoid dfs(int node, vector<int> adj[], vector<int> &dp, vector<int>& informTime){\n for(auto it: adj[node]){\n dfs(it, adj, dp, informTime);\n dp[node] = max(informTime[node] + dp[it], dp[node]);\n }\n}\n int numOfMinutes(int n, int headID, vector<int>& mana...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\nvoid dfs(int node, vector<int> adj[], vector<int> &dp, vector<int>& informTime){\n for(auto it: adj[node]){\n dfs(it, adj, dp, informTime);\n dp[node] = max(informTime[node] + dp[it], dp[node]);\n }\n}\n int numOfMinutes(int n, int headID, vector<int>& mana...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\nvoid dfs(int node, vector<int> adj[], vector<int> &dp, vector<int>& informTime){\n for(auto it: adj[node]){\n dfs(it, adj, dp, informTime);\n dp[node] = max(informTime[node] + dp[it], dp[node]);\n }\n}\n int numOfMinutes(int n, int headID, vector<int>& mana...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n const static int MX = 1e5+1;\n vector<int> adj_list[MX];\n vector<bool> visited;\n vector<int> t;\n \n int dfs(int i) {\n visited[i] = true;\n \n int ret = 0;\n for (int x : adj_list[i]) {\n if (!visited[x])\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n queue<int>q;\n q.push(headID);\n\n vector<int>adj[n];\n for(int i=0;i<n;i++)\n {\n int mgr = manager[i];\n if(mgr==-1) continue;\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n int min[n];\n for (int i=0;i<n;i++) min[i]=99999999;\n vector<int> x[n...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> a[n];\n for (int i=0;i<n;i++) {\n if (i != headID) {\n a[manager[i]].push_back(i);\n }\n }\n int ans = 0;\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n int min[n];\n for (int i=0;i<n;i++) min[i]=99999999;\n vector<int> x[n];\n for (int i=0;i<n;i++){\n if (i==headID) continue;\n x[manager[i]...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> arr[n];\n int sum=0;\n for(int i=0; i<n; i++){\n if(manager[i]!=-1){\n arr[manager[i]].push_back(i);\n }\n }\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n typedef pair<int,int> P;\n int numOfMinutes(int n, int head, vector<int>& m, vector<int>& t) {\n vector<P>adj[n];\n for(int i=0;i<n;i++){\n if(m[i]!=-1) adj[m[i]].push_back({i,t[m[i]]});\n }\n vector<int> time(n,1e9);\n time[hea...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime){\n vector<pair<int, int>> adj[n];\n for(int i=0; i<manager.size(); i++)\n if(manager[i]!=-1)\n adj[manager[i]].push_back({i, informTime[manager[i]]});\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int>adj[n];\n\n for(int i = 0; i<n; i++)\n {\n if(manager[i]!=-1)\n adj[manager[i]].push_back(i);\n }\n\n queue<int>q;\n\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int maxTime = INT_MIN;\n \n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> adjList[n];\n \n // Making an adjacent list, each index stores the Ids of subordinate employees.\n for (int i = 0; ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<pair<int,int>>adj[n];\n for(int i=0;i<n;i++){\n int mang=manager[i];\n int subordinate=i;\n\n if(mang!=-1)adj[mang].push_back({i,inform...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<pair<int,int>>adj[n];\n for(int i=0;i<n;i++){\n int mang=manager[i];\n int subordinate=i;\n\n if(mang!=-1)adj[mang].push_back({i,inform...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int bfs(int head, vector<int>& manager, vector<int>& informTime,vector<int>adj[],vector<int>&vis){\n queue<pair<int,int>>q;\n vis[head]=1;\n int ans=0;\n q.push({head,0});\n while(!q.empty()){\n int node=q.front().first;\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
0
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int> dist(n,1e9);\n queue<pair<int,int>> pq;\n vector<int> adj[n];\n dist[headID]=0;\n int time=0,i;\n pq.push({0,headID});\n for(i=...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n\n vector<pair<int,int>>adj[n];\n int src;\n\n for(int i=0;i<manager.size();i++){\n if(manager[i] != -1) {adj[manager[i]].push_back({i,informTime[i]});}\n e...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n\n vector<pair<int,int>>adj[n];\n int src;\n\n for(int i=0;i<manager.size();i++){\n if(manager[i] != -1) {adj[manager[i]].push_back({i,informTime[i]});}\n e...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n\n void dfs(int ID, vector<int>& informTime, vector<vector<int>>& subordinates, int& timeInform, int& res){\n timeInform += informTime[ID];\n if(timeInform > res){\n res = timeInform;\n }\n\n for(int sub : subordinates[ID]){\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<vector<int>> subs(n);\n \n for (int i = 0; i < n; ++i) {\n if (i == headID) {\n continue;\n }\n subs[manager[i]]....
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int head, vector<int>& manager, vector<int>& inform) {\n vector<vector<pair<int,int>>> adj(n,vector<pair<int,int>>());\n for(int i=0; i<n; i++){\n if(manager[i] == -1) continue;\n adj[manager[i]].push_back({i,inform[...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
1
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int head, vector<int>& manager, vector<int>& inform) {\n vector<vector<pair<int,int>>> adj(n,vector<pair<int,int>>());\n for(int i=0; i<n; i++){\n if(manager[i] == -1) continue;\n adj[manager[i]].push_back({i,inform[...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<vector<int>> adj(n, vector<int>()); \n\n for (int v = 0; v < manager.size(); v++) {\n if (v == headID)\n continue;\n int& u = manag...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headId, vector<int>& manager, vector<int>& informTime) {\n queue<pair<int, int>> q;\n q.push({headId, 0});\n int res=0;\n vector<vector<int>> adj(n);\n for(int i=0; i<n; i++) {\n if(manager[i]!=-1) adj[...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n\n void dfs(int n,vector<vector<pair<int,int>>>&adj,vector<int>&time,vector<int>&vis){\n for(auto it:adj[n]){\n time[it.first]=min(time[it.first],time[n]+it.second);\n dfs(it.first,adj,time,vis);\n }\n }\n\n int numOfMinutes(int n, int...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\nvector<int> vis;\nvector<int> dis;\nvector<vector<pair<int,int>>> adj;\n\nvoid dijkstra(int st)\n{\n priority_queue<pair<int,int>> pq;\n pq.push({0,st});\n dis[st] = 0;\n while(!pq.empty())\n {\n pair<int,int> fs = pq.top();\n pq.pop();\n if(vi...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n if(n==1) return 0;\n vector<vector<int>> adj(n, vector<int>());\n for(int i=0;i<n;i++){\n if(manager[i]!=-1){\n adj[manager[i]].push_back(i);\...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<vector<int>> adj(n+1);\n\n for(int i=0;i<n;i++)\n {\n if (manager[i] != -1) \n { \n adj[manager[i]].push_back(i);\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "#define node pair<int, int>\nclass Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) \n {\n vector<vector<node>> adj(n);\n int maxMin = -1;\n for (int i = 0; i < n; i++)\n {\n if (manager[i] != -1)\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "#define node pair<int, int>\nclass Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) \n {\n vector<vector<node>> adj(n);\n int maxMin = -1;\n for (int i = 0; i < n; i++)\n {\n if (manager[i] != -1)\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int solve(int src,int par,vector<int>edges[],vector<int>&time){\n int t=0;\n for(auto E:edges[src]){\n if(E==par)continue;\n t=max(solve(E,src,edges,time),t);\n }\n return t+time[src];\n }\n int numOfMinutes(int n, int h...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int solve(int src,int par,vector<int>edges[],vector<int>&time){\n int t=0;\n for(auto E:edges[src]){\n if(E==par)continue;\n t=max(solve(E,src,edges,time),t);\n }\n return t+time[src];\n }\n int numOfMinutes(int n, int h...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n\n int dfs(int node, vector<int>adj[], vector<int>&vis, vector<int>& informTime)\n {\n vis[node] = 1;\n int a = 0;\n int maxi = 0;\n for(auto it: adj[node])\n {\n if(!vis[it])\n {\n a = informTime[nod...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n\nint res=0;\n\nvoid dfs(vector<int>adjList[],int node,vector<int>& vis,int time,vector<int>& informTime){\n vis[node]=1;\n res=max(res,time);\n\n for(auto &it:adjList[node]){\n if(!vis[it]){\n dfs(adjList,it,vis,time+informTime[node],informTime);\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<int>adj[n];\n for(int i=0;i<manager.size();i++){\n if(manager[i]!=-1){\n adj[i].push_back(manager[i]);\n adj[manager[i]].push_b...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<vector<int>> adj(n);\n\n for (int i = 0; i < manager.size(); i++) {\n int mngr = manager[i];\n int emp = i;\n\n if (mngr != -1) {\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<list<int>>gp(n, list<int>());\n for(int i=0; i<n; i++){\n if(manager[i] != -1){\n gp[manager[i]].push_back(i);\n }\n }\n\n ...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n vector<list<int>> adj(n);\n for(int i=0;i<n;i++){\n if(headID!=i){\n adj[manager[i]].push_back(i);\n }\n }\n queue<pair<int,...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n \n vector<vector<int>> adjList(n);\n\n for(int i=0;i<n;i++)\n {\n if(manager[i]!=-1) adjList[manager[i]].push_back(i);\n }\n\n\n queue<p...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int time=0;\n void dfs(int node,int par,int curr,vector<int>adj[],vector<int>&inft){\n \n for(auto child:adj[node]){\n if(child != par){\n curr+=inft[node];\n time=max(time,curr);\n dfs(child,no...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {\n \n vector<int>adj[n];\n for(int i=0;i<manager.size();i++){\n if(manager[i]==-1) continue;\n adj[i].push_back(manager[i]);\n adj[manager[i]].p...
1,492
<p>A company has <code>n</code> employees with a unique ID for each employee from <code>0</code> to <code>n - 1</code>. The head of the company is the one with <code>headID</code>.</p> <p>Each employee has one direct manager given in the <code>manager</code> array where <code>manager[i]</code> is the direct manager of...
2
{ "code": "class Solution {\npublic:\n int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& inform) {\n vector<int> adj[n];\n for(int i=0;i<manager.size();i++){\n if(manager[i]!=-1){\n adj[manager[i]].push_back(i);\n adj[i].push_back(manager[...