DFS
python3 []\nclass Solution:\n    def countHighestScoreNodes(self, parents: List[int]) -> int:\n        graph = defaultdict(list)\n        for i in range(len(par
```python3 []\nclass Solution:\n    def countHighestScoreNodes(self, parents: List[int]) -> int:\n        graph = defaultdict(list)\n        for i in range(len(parents)) :\n            graph[parents[i]].append(i)\n        \n        total = len(parents) - 1 \n        answer = defaultdict(int)\n\n        def dfs(node) :\n            if node is None :\n                return 0\n\n            if node not in graph :\n                answer[total] += 1\n                return 1\n\n            left, right = (graph[node] + [None for _ in range(2)])[ : 2]\n            left_count, right_count = dfs(left), dfs(right)\n\n            score = (\n                (right_count * (\n                    total - right_count if node else 1)) if not left_count else \n                (left_count * (\n                    total - left_count if node else 1)) if not right_count else \n                (left_count * right_count * (\n                    total - (left_count + right_count) if node else 1\n                ))\n            ) \n\n            answer[score] += 1\n            return left_count + right_count + 1\n        \n        dfs(0)\n        max_score = max(answer.keys())\n        return answer[max_score]\n        \n```
['Python3']