[Python3] Math + Topological Sort - Simple Solution
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```\nclass Solution:\n    def componentValue(self, nums: List[int], edges: List[List[int]]) -> int:\n        n, s = len(nums), sum(nums)\n        if n < 2: return 0\n        g = [[] for _ in range(n)]\n        in_degree = [0 for _ in range(n)]\n        for u, v in edges:\n            g[u].append(v)\n            g[v].append(u)\n            in_degree[u] += 1\n            in_degree[v] += 1\n        \n        def is_cuttable(f: int) -> bool:\n            d, values = in_degree.copy(), nums.copy()\n            dq = collections.deque(u for u in range(n) if d[u] == 1)\n            while dq:\n                u = dq.popleft()\n                d[u] = 0\n                if values[u] > f: return False\n                elif values[u] == f: values[u] = 0\n                for v in g[u]:\n                    if d[v] == 0: continue\n                    d[v] -= 1\n                    values[v] += values[u]\n                    if d[v] == 1: dq.append(v)\n            return True\n\n        factor_nums = [i for i in range(1, s + 1) if s % i == 0]\n        for f in factor_nums:\n            if is_cuttable(f): return s // f - 1\n        \n        return 0\n```\n\nThis is similar to this [problem](https://leetcode.com/problems/maximum-number-of-k-divisible-components/solutions/4870785/python3-cut-leaf-bfs-topological-sort-simple-solution/)
['Math', 'Topological Sort', 'Python3']