[Kotlin] Easy solution, time O(n), space O(1)
Approach\n- Step 1: For any two non-adjacent nodes U and V in the tree we can replace their values with the XOR values\n- Step 2: If the number of netChange is 
# Approach\n- Step 1: For any two non-adjacent nodes U and V in the tree we can replace their values with the XOR values\n- Step 2: If the number of netChange is positive is even, we can return current sum\n- Step 3: If the number of netChange is positive is odd, we have to reduce minChange\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\n    fun maximumValueSum(nums: IntArray, k: Int, edges: Array<IntArray>): Long {\n        var sum = 0L\n        var minChange = Int.MAX_VALUE\n        var count = 0\n        for (num in nums) {\n            val xorValue = num xor k\n            sum += maxOf(num, xorValue)\n            if (xorValue >= num) count++\n            minChange = minOf(minChange, abs(xorValue - num))\n        }\n        return if (count and 1 == 0) sum else sum - minChange\n    }\n}\n```
['Kotlin']