ATS resume help
前往频道在 Telegram
WhatsApp Me https://wa.me/917674087200 ✅ ATS-Friendly Resumes ✅ Higher Interview Calls ✅ Free Tips + Templates
显示更多3 723
订阅者
-524 小时
-217 天
-5230 天
帖子存档
3 723
long long num=0;
long long cost_node=0;
vis[node]=1;
for(auto a:adj[node]){
if(vis[a]==-1){
// cost++;
dfs(a,adj,child,vis,cost);
// cost--;
cost_node+=cost[a]+child[a];
num+=child[a];
}
}
// if(num==0)
// child[node]=1;
// else
child[node]=num+1;
cost[node]=cost_node;
}
long long minDistance(int n, vector> &edges) {
// code here
if(n==1)
return 0;
vectoradj[n];
for(auto a:edges){
adj[a[0]].push_back(a[1]);
adj[a[1]].push_back(a[0]);
}
vectorvisit(n,-1);
vectorchild(n,0);
vectorcost(n,0);
long long costt=0;
dfs(0,adj,child,visit,cost);
// for(int i=0;iq;
q.push(0);
int deep=0;
vectorvis(n,-1);
long long less=cost[0];
while(q.size()>0){
int l=q.size();
for(int i=0;i=1){
less=min(less,(cost[0]-(deep*(child[a]))));
}
q.push(a);
}
}
}
deep++;
}
// cout<
3 723
class Solution:
def findPathSum(self , tree, node, vis, pathSum):
childPathSum =0;
vis[node] = True;
for nbr in tree[node]:
if nbr not in vis:
childPathSum += self.findPathSum(tree,nbr,vis,pathSum +1)
return childPathSum + pathSum
def helper(self,tree,node,vis,pathSum,anss):
childs =1
vis[node]=True;
for nbr in tree[node]:
if nbr not in vis:
childs += self.helper(tree,nbr,vis,pathSum+1,anss)
anss[0] = max(anss[0],(pathSum -1)*childs)
return childs;
def minDistance(self, n, adj):
tree = adj
maxi = self.findPathSum(tree,0,{},0)
ans = maxi
for nbr in tree[0]:
anss = [float("-inf")]
deductionPossible = self.helper(tree,nbr,{0:True},1,anss)
ans = min(ans,maxi-anss[0])
return ans
3 723
class Solution:
def findPathSum(self , tree, node, vis, pathSum):
childPathSum =0;
vis[node] = True;
for nbr in tree[node]:
if nbr not in vis:
childPathSum += self.findPathSum(tree,nbr,vis,pathSum +1)
return childPathSum + pathSum
def helper(self,tree,node,vis,pathSum,anss):
childs =1
vis[node]=True;
for nbr in tree[node]:
if nbr not in vis:
childs += self.helper(tree,nbr,vis,pathSum+1,anss)
anss[0] = max(anss[0],(pathSum -1)*childs)
return childs;
def minDistance(self, n, adj):
tree = adj
maxi = self.findPathSum(tree,0,{},0)
ans = maxi
for nbr in tree[0]:
anss = [float("-inf")]
deductionPossible = self.helper(tree,nbr,{0:True},1,anss)
ans = min(ans,maxi-anss[0])
return ans
3 723
Share our channel❤️
-->@Coding_Palace
Make 30 more subscribers
I will send q3 also in text format ✅
3 723
class Solution:
def isPossible(self, n, m, c, arr, maxWaitingTime):
firstStudentArrivalTime = -(maxWaitingTime + 1)
studentsOnboarded = 0
bussNeeded = 0
for time in arr:
if time - firstStudentArrivalTime > maxWaitingTime or studentsOnboarded > c:
bussNeeded +=1
firstStudentArrivalTime = time
studentOnboarded = 0
studentOnboarded += 1
return bussNeeded <= m
def minimumWaitTime(self, n , m, c, arr):
arr.sort()
low, high=0, arr[-1] - arr[0]
ans=high
while low <= high:
mid= low + (high-low)//2
if self.isPossible(n,m,c,arr,mid):
ans=mid
high=mid-1
else:
low=mid+1
return ans
3 723
Share our channel❤️
-->@Coding_Palace
Make 30 more subscribers
I will send codes in text format also✅
3 723
Share our channel
@Coding_Palace
Make 30 more subscribers
I will send codes in text format also✅
