There exists an undirected tree with n nodes labeled from n nums of length n, where nums[i] represents the value of the k and a edges of length n edges[i] [u, v] indicates an undirected edge between nodes u and v in the tree.
You can perform the following operation any number of times (including zero times):
Choose an edge [u, v] connecting nodes u and v.
Update nums[u] to be nums[u] XOR k.
Update nums[v] to be nums[v] XOR k.
Return the maximum possible sum of the values of all nodes in the tree after applying the operation any number of times.
Constraints:
n nums.length
k
nums[i]
edges.length n
edges[i].length
edges[i][0], edges[i][1] n
The input is generated such that edges represents a valid tree.
There exists an undirected tree with n nodes labeled from n nums of length n, where nums[i] represents the value of the k and a edges of length n edges[i] [u, v] indicates an undirected edge between nodes u and v in the tree.
You can perform the following operation any number of times (including zero times):
Choose an edge [u, v] connecting nodes u and v.
Update nums[u] to be nums[u] XOR k.
Update nums[v] to be nums[v] XOR k.
Return the maximum possible sum of the values of all nodes in the tree after applying the operation any number of times.
Constraints:
n nums.length
k
nums[i]
edges.length n
edges[i].length
edges[i][0], edges[i][1] n
The input is generated such that edges represents a valid tree.