Very simple and straightforward dfs solution
Intuition\nFirst think if the nums is not there then how you approach\n\n# Approach\nstep1 -> Find the all the divisors of sum(nums[i])\nstep -> check for each 
# Intuition\nFirst think if the nums is not there then how you approach\n\n# Approach\nstep1 -> Find the all the divisors of sum(nums[i])\nstep -> check for each divisor wheather can we split into sum/divisor or not If yes the update ans as max(ans,divisor-1);\n\n# Complexity\n- Time complexity:\nO(Number of node*no of divisor of sum(nums[i])+ sum(nums[i]))\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n\nbool flag;        // yes can split\nint dfs(int curr,vector <vector<int>> &adj,int par,int k,vector <int> &cost)\n{\n    int ans = cost[curr];\n    for(auto &x:adj[curr])\n    {\n        if(par!=x)\n        ans+=dfs(x,adj,curr,k,cost);\n    }\n    if(ans>k)\n    {\n        flag = false;\n        return 0;\n    }\n    else if(ans==k)\n        ans=0;\n    return ans;\n}\n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) {\n        int n = nums.size();\n        vector <vector<int>> adj(n);\n        for(auto &x:edges)\n        {\n            adj[x[0]].push_back(x[1]);\n            adj[x[1]].push_back(x[0]);\n        }\n        int sum = 0;\n        int maxEdgeCanRemove = 0;\n        for(auto &x:nums) sum+=x;\n        for(int i=1;i<=sum;i++)\n        {\n            if(sum%i==0)\n            {\n                flag = true;\n                dfs(0,adj,-1,sum/i,nums);\n                if(flag)\n                maxEdgeCanRemove = max(maxEdgeCanRemove,i-1);\n            }\n        }\n        return maxEdgeCanRemove;\n    }\n};\n```
['Depth-First Search', 'Number Theory', 'C++']