C++ || Easy To Understand || 100% Fast Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nDiving the total sum into equal parts and then simply DFS call\n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDiving the total sum into equal parts and then simply DFS call\n\n# Complexity\n- Time complexity:O(N*root(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) {\n         int n=nums.size();\n        vector<vector<int>> adj(n);\n        int sum=0;\n         for (int i=0; i<n; ++i)\n            sum+=nums[i];\n        for(auto &x:edges)\n        {\n            adj[x[0]].push_back(x[1]);\n            \n            adj[x[1]].push_back(x[0]);\n        }\n       \n       for(int i=n;i>1;i--)\n       {\n           if(sum%i) continue;\n         \n           if(dfs(nums,adj,0,-1,sum/i)==0)\n           return i-1;\n       }\n       return 0;\n    }\n    private:\n    int dfs(vector<int> &nums,vector<vector<int>> &adj,int node,int par,int target)\n    {\n        int s=nums[node];\n        for(auto &it:adj[node])\n        {\n            if(it==par) continue;\n            s+=dfs(nums,adj,it,node,target);\n        }\n        if(s==target)\n        return 0;\n        else\n        return s;\n    }\n};\n```
['C++']