Easy to Understand Pythonic Solution
\nclass Solution:\n    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:\n        \n        n=len(cost)\n        \n        adj=[]\n  
```\nclass Solution:\n    def placedCoins(self, edges: List[List[int]], cost: List[int]) -> List[int]:\n        \n        n=len(cost)\n        \n        adj=[]\n        \n        for i in range(n):\n            adj.append([])\n            \n        for node1,node2 in edges:\n            adj[node1].append(node2)\n            adj[node2].append(node1)\n            \n        ans=[1]*n\n        \n        def numSubTree(curNode,parent):\n            curCost=cost[curNode]\n            a,b,c=curCost,-1,-1 \n            min1,min2=curCost,float(\'inf\')\n            curSize=1\n            \n            for neigh in adj[curNode]:\n                if neigh!=parent:\n                    subSize,sa,sb,sc,smin1,smin2=numSubTree(neigh,curNode)\n                    curSize+=subSize\n                    \n                    for num in [sa,sb,sc]:\n                        if num>a:\n                            c=b\n                            b=a\n                            a=num\n                        elif num>b:\n                            c=b\n                            b=num\n                        elif num>c:\n                            c=num\n\n                    for num in [smin1,smin2]:\n                        if num<min1:\n                            min2=min1\n                            min1=num\n                        elif num<min2:\n                            min2=num\n\n            if curSize>=3:\n                cost1=a*b*c\n                if min1<0 and min2<0:\n                    cost1=max(cost1,a*min1*min2)\n                \n                ans[curNode]=cost1 \n                if ans[curNode]<0:\n                    ans[curNode]=0\n            \n\n            return curSize,a,b,c,min1,min2\n        \n        numSubTree(0,-1)\n    \n        return ans\n```
['Python']