You are given an integer n representing the number of nodes in an undirected tree rooted at node edges of length edges[i] cost of length n, where cost[i] is the cost associated with node i.
The score of a path from the root node
You can increase the cost of any node by any positive integer amount.
Return the minimum number of nodes whose costs must be increased such that every root to leaf path has the exact same score.
Constraints:
n
edges.length
edges[i]
n
cost.length
cost[i]
The input is generated such that edges represents a valid tree.
You are given an integer n representing the number of nodes in an undirected tree rooted at node edges of length edges[i] cost of length n, where cost[i] is the cost associated with node i.
The score of a path from the root node
You can increase the cost of any node by any positive integer amount.
Return the minimum number of nodes whose costs must be increased such that every root to leaf path has the exact same score.
Constraints:
n
edges.length
edges[i]
n
cost.length
cost[i]
The input is generated such that edges represents a valid tree.