Easy to read and understand solution. O(n) time and space complexity
IntuitionWe need to calculate sum of subtrees on every node, than we can find out how many nodes will be in the tree without any one.ApproachBuild a map of node
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to calculate sum of subtrees on every node, than we can find out how many nodes will be in the tree without any one.
# Approach
<!-- Describe your approach to solving the problem. -->
Build a map of nodes, than calculcate number of nodes on every one by dfs, than findout number of nodes without current one, and count how many times deleting node gives us the maximum number of nodes.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n)

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

# Code
```java []
class Solution {
    public int countHighestScoreNodes(int[] parents) {
        long[] result = new long[parents.length];
        long max = 0;
        int[][] map = new int[parents.length][2];
        for (int i = 0; i < parents.length; i++) {
            Arrays.fill(map[i], -1);
        }

        for (int i = 1; i < parents.length; i++) {
            int to = parents[i];
            if (map[to][0] == -1) {
                map[to][0] = i;
            } else {
                map[to][1] = i;
            }
        }

        int[] count = new int[parents.length];
        dfs(count, 0, map);

        for (int i = 0; i < result.length; i++) {
            int left = map[i][0];
            int right = map[i][1];
            int leftSum = left == - 1 ? 0 : count[left];
            int rightSum = right == - 1 ? 0 : count[right];
            int topSum = count[0] - leftSum - rightSum - 1;
            result[i] = 1;
            result[i] *= leftSum == 0 ? 1 : leftSum;
            result[i] *= rightSum == 0 ? 1 : rightSum; 
            result[i] *= topSum == 0 ? 1 : topSum;
            max = Math.max(max, result[i]);
        }
        int res = 0;
        for (int i = 0; i < result.length; i++) {
            res += result[i] == max ? 1 : 0;
        }
        return res;
    }

    private int dfs(int[] count, int idx, int[][] map) {
        int left = map[idx][0] == -1 ? 0 : dfs(count, map[idx][0], map);
        int right = map[idx][1] == -1 ? 0 : dfs(count, map[idx][1], map);
        count[idx] = left + right + 1;
        return count[idx];
    }
}
```
['Java']