Python (Simple DFS)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def componentValue(self, nums, edges):\n        n, total, max_val, min_val, graph = len(nums), sum(nums), max(nums), min(nums), defaultdict(list)\n\n        for i,j in edges:\n            graph[i].append(j)\n            graph[j].append(i)\n\n        dict1 = defaultdict(int)\n\n        def function(node,parent):\n            result = nums[node]\n\n            for neighbor in graph[node]:\n                if neighbor != parent:\n                    result += function(neighbor,node)\n\n            dict1[result] += 1 \n\n            return result\n\n        function(0,-1)\n\n        for target in range(max_val,total):\n            count = 0\n            if total%target == 0:\n                for key,val in dict1.items():\n                    if key%target == 0:\n                        count += val \n                if count == total//target:\n                    return total//target - 1 \n\n        return 0\n```
['Python3']