Practice Maximum Points After Collecting Coins From All Nodes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Points After Collecting Coins From All Nodes
Problem Statement
The tree is rooted at node 0, with undirected edges and coins[i] initially at node i. Collect a node only after all its ancestors. At each node, either collect its current coin count and gain that count minus k points, or gain floor(current count / 2) points and halve the coin counts of every node in its subtree, rounding down. Halving effects accumulate. Return the greatest total after collecting every node.
Source: Maximum Points After Collecting Coins From All Nodes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
edges = [[0,1],[1,2],[2,3]], coins = [10,10,3,3], k = 5
11
# Example 2
edges = [[0,1],[0,2]], coins = [8,4,4], k = 0
16
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Points After Collecting Coins From All Nodes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.