Easy C++ Solution || Using DP (Beats 100%) ✅✅
Code\n\nclass Solution {\npublic:\n    long long helper(int i,vector<int>& values,vector<vector<long long>> &dp,int n,int count,int k){\n        if(i==n){\n    
# Code\n```\nclass Solution {\npublic:\n    long long helper(int i,vector<int>& values,vector<vector<long long>> &dp,int n,int count,int k){\n        if(i==n){\n            if(count==0){\n                return 0;\n            }else{\n                return INT_MIN;\n            }\n        }\n        if(dp[i][count]!=-1){\n            return dp[i][count];\n        }\n        long long x=(values[i]^k) + helper(i+1,values,dp,n,!count,k);\n        long long y=values[i] + helper(i+1,values,dp,n,count,k);\n        return dp[i][count]=max(x,y);\n    }\n    long long maximumValueSum(vector<int>& nums, int k, vector<vector<int>>& edges) {\n        int n=nums.size();\n        vector<vector<long long>> dp(n,vector<long long>(2,-1));\n        return helper(0,nums,dp,n,0,k);\n    }\n};\n```
['Dynamic Programming', 'Tree', 'Recursion', 'C++']