Can Somebody find Error in Above Code
Code\n\n// class Solution {\n//     public long maximumValueSum(int[] nums, int k, int[][] edges) {\n//         int n = nums.length;\n//         int[] vis = new
# Code\n```\n// class Solution {\n//     public long maximumValueSum(int[] nums, int k, int[][] edges) {\n//         int n = nums.length;\n//         int[] vis = new int[n];\n//         for (int i = 0; i < n - 1; i++) {\n//             vis[edges[i][0]] = edges[i][0];\n//             vis[edges[i][0]] = edges[i][0];\n//         }\n\n//         List<Integer> list = new ArrayList<>();\n//         for (int i = 0; i < n; i++) {\n//             long val = (long) Math.pow(nums[i], k);\n//             if (val > nums[i]) {\n//                 list.add(i);\n//             }\n//         }\n\n//         int size = list.size();\n//         if (size % 2 == 0) {\n//             long ans = 0;\n//             for (int i = 0; i < n; i++) {\n//                 ans += nums[i];\n//             }\n//             for (int i = 0; i < list.size(); i++) {\n//                 ans -= nums[list.get(i)];\n//                 long add = (long) Math.pow(nums[list.get(i)], k);\n//                 ans += add;\n//             }\n//             return ans;\n//         } else {\n//             long ans = 0;\n//             for (int i = 0; i < n; i++) {\n//                 ans += nums[i];\n//             }\n\n//             long res = ans;\n//             for (int i = 0; i < list.size(); i++) {\n//                 ans -= nums[list.get(i)];\n//                 long add = (long) (Math.pow(nums[list.get(i)], k));\n//                 ans += add;\n//             }\n//             for (int i = 0; i < size; i++) {\n//                 long add = (long) Math.pow(nums[list.get(i)], k);\n//                 long cur = ans - add + nums[list.get(i)];\n//                 res = Math.max(res, cur);\n//             }\n\n//             int[] temp = new int[n];\n//             Arrays.fill(temp, 0);\n//             long sum = 0;\n//             for (int i = 0; i < size; i++) {\n//                 temp[list.get(i)] = 1;\n//             }\n//             for (int i = 0; i < n; i++) {\n//                 if (temp[i] == 0) {\n//                     long add = (long) (Math.pow(nums[i], k));\n//                     long cur = ans - nums[i] + add;\n//                     res = Math.max(res, cur);\n//                 }\n//             }\n//             return res;\n//         }\n//     }\n// }\n\nclass Solution {\n    public long maximumValueSum(int[] nums, int k, int[][] edges) {\n        long res = 0;\n        int diff = 1 << 30, c = 0;\n        for (int num : nums) {\n            int b = num ^ k;\n            res += Math.max(num, b);\n            c ^= num < b ? 1 : 0;\n            diff = Math.min(diff, Math.abs(num - b));\n        }\n        return res - diff * c;\n    }\n}\n```
['Array', 'Dynamic Programming', 'Greedy', 'Bit Manipulation', 'Tree', 'Java']