Java Solution NO DFS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long maximumValueSum(int[] nums, int k, int[][] edges) {\n        int n = nums.length;\n        int count = 0;\n        int max = Integer.MAX_VALUE;\n        int min = Integer.MAX_VALUE;\n        long ans = 0;\n        for(int i = 0; i < n; i++){\n            if((nums[i] ^ k) > nums[i]){\n                max = Math.min(max, (nums[i] ^ k) - nums[i]);\n                ans += (nums[i] ^ k);\n                count++;\n            }else{\n                min = Math.min(min, nums[i] - (nums[i] ^ k));\n                ans += nums[i];\n            }\n        }\n        if(count % 2 != 0){\n            ans -= Math.min(max, min);\n        }\n        return ans;\n    }\n}\n```
['Java']