
There exists an undirected tree with n nodes numbered 0 to n - 1 . You are given a 2D integer array edges of length n - 1 , where edges[i] = [u _i , v _i , w _i ] indicates that there is an edge between nodes u _i and v _i with weight w _i in the tree.
Your task is to remove zero or more edges such that:
Each node has an edge with at most k other nodes, where k is given.
The sum of the weights of the remaining edges is maximized .
Return the maximum possible sum of weights for the remaining edges after making the necessary removals.
2 <= n <= 10 ^51 <= k <= n - 1edges.length == n - 1edges[i].length == 30 <= edges[i][0] <= n - 10 <= edges[i][1] <= n - 11 <= edges[i][2] <= 10 ^6The input is generated such that edges form a valid tree.