C++ dfs faster than 70%
\nclass Solution {\npublic:\n    int b,sum;\n    vector<int> F;\n    void dfs(int x,int limit,vector<int>& nums,vector<vector<int>>& A,vector<int>& kt,vector<in
```\nclass Solution {\npublic:\n    int b,sum;\n    vector<int> F;\n    void dfs(int x,int limit,vector<int>& nums,vector<vector<int>>& A,vector<int>& kt,vector<int>& value)\n    {\n        kt[x]=1;\n        value[x]=nums[x];\n        for(int i=0;i<=A[x].size()-1;i++)\n        {\n            if(kt[A[x][i]]==0)\n            {\n                dfs(A[x][i],limit,nums,A,kt,value);\n                if(b==1) return;\n                value[x]=value[x]+value[A[x][i]];\n            }\n        }\n        if(value[x]>limit) b=1;\n        else if(value[x]==limit) value[x]=0;\n    }\n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) {\n        if(edges.empty()!=0) return 0;\n        vector<int> kt,temp(nums.size(),0),value;\n        vector<vector<int>> A(nums.size());\n        for(int i=0;i<=edges.size()-1;i++)\n        {\n            A[edges[i][0]].push_back(edges[i][1]);\n            A[edges[i][1]].push_back(edges[i][0]);\n        }\n        for(int i=0;i<=nums.size()-1;i++)\n            sum=sum+nums[i];\n        for(int i=1;i<=sum;i++)\n            if(sum%i==0) F.push_back(i);\n        for(int i=0;i<=F.size()-1;i++)\n        {\n            b=0;\n            kt=temp;\n            value=temp;\n            dfs(0,F[i],nums,A,kt,value);\n            if(b==0) return sum/F[i]-1;\n        }\n        return 0;\n    }\n};\n```
['Depth-First Search', 'C']