Python || Factorization || DFS
Time Complexity - O(sqrt(sum)*n)\n\nclass Solution:\n    def componentValue(self, nums: List[int], edges: List[List[int]]) -> int:\n        ssum=sum(nums)\n    
Time Complexity - O(sqrt(sum)*n)\n```\nclass Solution:\n    def componentValue(self, nums: List[int], edges: List[List[int]]) -> int:\n        ssum=sum(nums)\n        n=len(nums)\n        facs=set()\n        for i in range(1,int(sqrt(ssum))+1):\n            if ssum%i==0: \n                facs.add(ssum//i)\n                facs.add(i)\n        graph=defaultdict(list)\n        for u,v in edges:\n            graph[u].append(v)\n            graph[v].append(u)\n        def dfs(node,par,gg):\n            nonlocal cnt\n            val=nums[node]\n            for nei in graph[node]:\n                if nei==par: continue\n                val+=dfs(nei,node,gg)\n            if val==gg:\n                cnt+=1\n                val=0\n            return val\n        for f in sorted(list(facs),reverse=True):\n            cnt=0\n            dfs(0,-1,ssum//f)\n            if cnt==f:\n                return f-1\n        return 0\n                    \n        \n```
['Depth-First Search', 'Python']