Python dfs simple
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def countHighestScoreNodes(self, parents: List[int]) -> int:
        n = len(parents)
        adj = { i : [] for i in range(n)}
        for i in range(n):
            if parents[i] != -1:
                adj[parents[i]].append(i)
        
        sizes = [0] * n

        def dfs(i):
            if not adj[i]:
                sizes[i] = 1
                return 1
            size = 0
            for n in adj[i]:
                size += dfs(n)

            sizes[i] = size + 1
            return sizes[i]
        dfs(0)

        scores = [0] * n
        for i in range(n):
            score = 1
            for n in adj[i]:
                score *= sizes[n]
            score *= max(1, sizes[0] - sizes[i])
            scores[i] = score
        
        #print(scores)
        c = Counter(scores)
        max_score = max(c)
        return c[max_score]



        

        
```
['Python3']