The bigger picture
IntuitionApproachComplexity

Time complexity:
O(n)


Space complexity:
O(n)

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

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

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(n)

# Code
```javascript []
/**
 * @param {number[]} parents
 * @return {number}
 */
var countHighestScoreNodes = function (parents) {
  let n = parents.length;
  let adj = Array(n)
    .fill(0)
    .map(() => []);
  for (let i = 1; i < n; i++) {
    adj[parents[i]].push(i);
  }
  let scores = new Map();
  let dfs = (node) => {
    if (!node && node !== 0) {
      return 0;
    }
    let children = adj[node];
    let left = children[0];
    let right = children[1];
    let leftCount = 0;
    let rightCount = 0;
    if (left) {
      leftCount = 1 + dfs(left);
    }
    if (right) {
      rightCount = 1 + dfs(right);
    }
    let rem = n - 1 - leftCount - rightCount;

    let score = (leftCount || 1) * (rightCount || 1) * (rem || 1);
    if (scores.has(score)) {
      scores.set(score, scores.get(score) + 1);
    } else {
      scores.set(score, 1);
    }
    return leftCount + rightCount;
  };
  dfs(0);
  let maxScore  = Math.max(...Array.from(scores.keys()))
  return scores.get(maxScore);
};
```
['JavaScript']