You are given a weighted tree consisting of edges of length edges[i] = [par_i, weight_i] indicates that node par_i is the parent of node i with an edge weight of weight_i. For the root node edges[0] = [-1, -1].
You want to select a subset of edges such that no two chosen edges share a common node.
Return the maximum possible sum of weights among the chosen edges.
Constraints:
n == edges.length
n
edges[i].length
par_0 weight_0
par_i n
par_i i
weight_i
edges represents a valid tree.
You are given a weighted tree consisting of edges of length edges[i] = [par_i, weight_i] indicates that node par_i is the parent of node i with an edge weight of weight_i. For the root node edges[0] = [-1, -1].
You want to select a subset of edges such that no two chosen edges share a common node.
Return the maximum possible sum of weights among the chosen edges.
Constraints:
n == edges.length
n
edges[i].length
par_0 weight_0
par_i n
par_i i
weight_i
edges represents a valid tree.