Fast Python approach using two DFS's
IntuitionNotice the problem requires an operation on each node, meaning DFS is applicable. Next, for each node, we need to know the size of the subtrees it is c
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Notice the problem requires an operation on each node, meaning DFS is applicable. Next, for each node, we need to know the size of the subtrees it is connected to. This information can also be calcualted with a DFS. 

# Approach
<!-- Describe your approach to solving the problem. -->
1. Use an array named sizes to store the size of the subtree under each node, including the node itself. 
2. Fill in this array by using a DFS that adds the count of all its neighbors and itself. 
3. With this sizes array filled, begin a new DFS to calculate the scores. For each node, if the node has a parent, multiply the score by the size of the entire tree minus the size of the current node's subtree. Then multiply score by the sizes of the neighboring subtrees. If the score is larger than the greatest seen so far, update the result. Then recurse for all other nodes. 
# Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$

# Code
```python3 []
class Solution:
    def countHighestScoreNodes(self, parents: List[int]) -> int:
        # Solve using two dfs's
        # First dfs to count the size of the subtree of each node
        # second dfs goes through and caluclates the score using previously counted sizes

        # First, construct the tree
        adj = [[] for i in range(len(parents))]
        for i in range(1, len(parents)):
            adj[parents[i]].append(i)

        # First dfs to count the size of each subtree
        sizes = [1 for i in range(len(parents))]
        self.count(0, sizes, adj)

        # Second dfs to calculate scores
        resPair = [0, 0]
        self.calculateScores(0, parents, adj, resPair, sizes)
        return resPair[1]

    def count(self, node, sizes, adj):
        for neighbor in adj[node]:
            self.count(neighbor, sizes, adj)
            sizes[node] += sizes[neighbor]
    
    def calculateScores(self, node, parents, adj, resPair, sizes):
        score = 1
        # If node has a parent, add to multiplication
        if parents[node] != -1:
            score *= sizes[0] - sizes[node]
        for neighbor in adj[node]:
            score *= sizes[neighbor]
        if score > resPair[0]:
            resPair[0] = score
            resPair[1] = 1
        elif score == resPair[0]:
            resPair[1] += 1
        
        for neighbor in adj[node]:
            self.calculateScores(neighbor, parents, adj, resPair, sizes)

```
['Python3']