C++ || DFS Commented code
C++ code\n\n int isPossible(int target, int src, vector<int> adj[], int par, vector<int> &nums){\n        int currSum=nums[src];\n        \n        for(auto &x:
**C++ code**\n```\n int isPossible(int target, int src, vector<int> adj[], int par, vector<int> &nums){\n        int currSum=nums[src];\n        \n        for(auto &x:adj[src]){\n            if(x!=par){\n                currSum+=isPossible(target,x,adj,src,nums);\n            }\n        }\n        \n        //if current node create pair with its child and found target so it will not going to give its value to its parent\n        if(currSum==target){\n            return 0;\n        }\n        return currSum;\n    }\n    \n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) {\n        vector<int> adj[nums.size()];\n        \n        //create graph\n        for(auto &x:edges){\n            adj[x[0]].push_back(x[1]);\n            adj[x[1]].push_back(x[0]);\n        }\n        \n        int sum=0;\n        for(auto &x:nums){\n            sum+=x;\n        }\n        // check for each possiblity\n        for(int i=nums.size()-1;i>=1;i--){\n            if(sum%(i+1)==0){\n                if(isPossible(sum/(i+1),0,adj,-1,nums)==0){\n                    return i;\n                }\n            }\n        }\n        return 0;\n    }\n\t//code by sachin\n```\n**Upvote if solution was helpful**
['Depth-First Search', 'C', 'C++']