[Python] Just DFS, nothing special
python\nclass Solution:\n    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:\n        g = defaultdict(list)\n        for a, b in ed
```python\nclass Solution:\n    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:\n        g = defaultdict(list)\n        for a, b in edges:\n            g[a].append(b)\n            g[b].append(a)\n\n        def dfs(i, p):\n            vals = [cost[i]]\n            for j in g[i]:\n                if j == p:\n                    continue\n                vals.extend(dfs(j, i))\n\n            vals.sort()\n            if len(vals) >= 3:\n                result[i] = max(\n                    0,\n                    vals[0] * vals[1] * vals[-1],\n                    vals[-1] * vals[-2] * vals[-3],\n                )\n\n            return vals\n                \n        result = [1]*len(cost)\n        dfs(0, -1)\n        return result\n```
['Depth-First Search', 'Python']