Python | XOR
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n    def maximumValueSum(self, nums: list[int], k: int, edges: list[list[int]]) -> int:\n 
[see the Successfully Accepted Submission](https://leetcode.com/problems/find-the-maximum-sum-of-node-values/submissions/1261915101/?envType=daily-question&envId=2024-05-19)\n\n# Code\n```\nclass Solution:\n    def maximumValueSum(self, nums: list[int], k: int, edges: list[list[int]]) -> int:\n        import sys\n        n = len(nums)\n        cnt = 0\n        sac = sys.maxsize  # Use sys.maxsize to represent INT_MAX\n        total_sum = 0\n        \n        for num in nums:\n            x = num\n            y = num ^ k\n            if x > y:\n                total_sum += x\n            else:\n                total_sum += y\n                cnt += 1\n            sac = min(sac, abs(x - y))\n        \n        if cnt % 2 == 1:\n            total_sum -= sac\n        \n        return total_sum\n```\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)
['Python3']