There is an undirected, unrooted tree consisting of n nodes labeled from n n and a edges of length n edges[i] price of length n, where price[i] denotes the price of the node i.
The price sum of a path is defined as the sum of the prices of all nodes visited along that path.
For any chosen root node, the cost is the difference between the maximum price sum of a path starting at the root and ending at any node, and the minimum price sum of a path starting at the root and ending at any node.
Return the maximum possible cost among all possible choices of the root node.
Constraints:
n
edges.length
edges represents a valid tree.
price.length
price[i]
There is an undirected, unrooted tree consisting of n nodes labeled from n n and a edges of length n edges[i] price of length n, where price[i] denotes the price of the node i.
The price sum of a path is defined as the sum of the prices of all nodes visited along that path.
For any chosen root node, the cost is the difference between the maximum price sum of a path starting at the root and ending at any node, and the minimum price sum of a path starting at the root and ending at any node.
Return the maximum possible cost among all possible choices of the root node.
Constraints:
n
edges.length
edges represents a valid tree.
price.length
price[i]