Practice Find the Maximum Sum of Node Values
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find the Maximum Sum of Node Values
Problem Statement
Given a tree on nodes 0 through n - 1 described by edges, node values nums, and a positive integer k, you may choose an edge [u, v] and replace both endpoint values with nums[u] XOR k and nums[v] XOR k. Repeat this operation any number of times, including zero. Return the maximum possible sum of all node values.
Source: Find the Maximum Sum of Node Values on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,2,1], k = 3, edges = [[0,1],[0,2]]
6
# Example 2
nums = [2,3], k = 7, edges = [[0,1]]
9
# Example 3
nums = [7,7,7,7,7,7], k = 3, edges = [[0,1],[0,2],[0,3],[0,4],[0,5]]
42
Constraints
Related LeetCode Problems
Practice more problems similar to Find the Maximum Sum of Node Values.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.