c++||DFS
int ans=0;\n    int dfs(vector adj[],int sv,int p,vector& nums,int sum,int & f){\n        int s=0;\n        for(auto c:adj[sv]){\n            if(c!=p){\n       
int ans=0;\n    int dfs(vector<int> adj[],int sv,int p,vector<int>& nums,int sum,int & f){\n        int s=0;\n        for(auto c:adj[sv]){\n            if(c!=p){\n                s+=dfs(adj,c,sv,nums,sum,f);\n               \n            }\n        }\n       if(s+nums[sv]==sum)return 0;\n        else if(s+nums[sv]>sum){\n            f=1;\n            return 0;\n        }\n        return s+nums[sv];\n        \n        \n    }\n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) {\n        int n=nums.size();\n        vector<int> adj[n];\n        for(auto e:edges){\n            adj[e[0]].push_back(e[1]);\n            adj[e[1]].push_back(e[0]);\n        }\n        \n       int sum=0;\n        for(auto k:nums)sum+=k;\n        for(int i=1;i<=sum;i++){\n            if(sum%i==0)\n            {\n                int f=0;\n            dfs(adj,0,0,nums,i,f);\n                if(f==0) {\n                    return sum/i-1;\n                }\n            }\n          \n        }\n        int f=0;\n            dfs(adj,0,0,nums,6,f);\n                if(f==0) {\n                    cout<<f<<" ";\n                }\n        return -1;\n        \n    }
['Depth-First Search']