shlogg · Early preview
Md Ariful Haque @mah-shamim

Maximum Sum Of Node Values Achievable With XOR Operation

Maximize node values sum in tree: XOR k with each node's value when edge is chosen. Return max achievable sum. Example: nums = [1,2,1], k = 3, edges = [[0,1],[0,2]] -> Output: 6.

3068. Find the Maximum Sum of Node Values
Hard
There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 0-indexed 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree. You are also given a positive integer k, and a 0-indexed array of non-negative integers nums of length n, where nums[i] represents the value of the node numbered i.
Alice wants the sum of values of tree nodes to be maximum, for which Alice can perform the following operation any number of times (including zero) on the tree:...