There is an undirected tree with n nodes rooted at node n edges of length n edges[i] coins of size n, where coins[i] represents the initial number of coins at node i, and an integer k.
You must collect all the coins from every node. You may collect coins from a node only after collecting coins from its parent.
For any node i, you can collect its coins using one of two methods:
Collect coins[i]
Collect i to be reduced to j.
Return the maximum total points you can collect after harvesting coins from all nodes in the tree.
Constraints:
n coins.length
n
coins[i]
edges.length n
edges[i][0], edges[i][1] n
k
There is an undirected tree with n nodes rooted at node n edges of length n edges[i] coins of size n, where coins[i] represents the initial number of coins at node i, and an integer k.
You must collect all the coins from every node. You may collect coins from a node only after collecting coins from its parent.
For any node i, you can collect its coins using one of two methods:
Collect coins[i]
Collect i to be reduced to j.
Return the maximum total points you can collect after harvesting coins from all nodes in the tree.
Constraints:
n coins.length
n
coins[i]
edges.length n
edges[i][0], edges[i][1] n
k