Best c++ solution ||  Beats 100%🎯
Intuition\n Describe your first thoughts on how to solve this problem. XORing an even number of times by the same element results in the original number.  \na ^
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->XORing an even number of times by the same element results in the original number.  \na ^ b ^ b = a --> The important property of XOR.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. For each element in the given array, store both the original value and the XOR-ed value with k in variables x and y respectively.\n\n2. Determine which value between x and y is greater and add it to the sum.\n\n3. If the XOR-ed value is greater, increment the counter cnt, which keeps track of the number of changes made.\n\n4. Calculate the sacrifice element, sac, by taking the minimum of the absolute difference between x and y.\n\n5. If the number of changes (cnt) is odd, remove the sacrifice (sac) from the sum and return the result.\n\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1)\n\n# Code\n```\n#include<bits/stdc++.h>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\npublic:\n    long long maximumValueSum(vector<int>& nums, int k, vector<vector<int>>& edges) {\n        int n = nums.size();\n        int cnt=0;\n        long long sac=INT_MAX,sum=0;\n       for(auto it:nums)\n       {\n           int x= it;\n           int y=it^k;\n           if(x>y)\n           {\n               sum+=x;\n           }\n           else\n           {\n               sum+=y;\n               cnt++;\n           }\n           sac=min(sac,static_cast<long long> (abs(x-y)));\n               \n       }if(cnt%2==1)\n           sum-=sac;\n        return sum;\n    }\n};\n\n```
['C++']