[LeetCode] Maximum Points After Collecting Coins From All Nodes

1 · · Oct. 29, 2023, 3:19 a.m.
2920. Maximum Points After Collecting Coins From All Nodes There exists an undirected tree rooted at node 0 with n nodes labeled from 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given a 0-indexed array coins of size n where coins[i] indicates the number of coins in the vertex i, and an integer k. Starting from the root, you have to collect all the coins such that t...