Java Solution || HashTables || DFS || O(n) time
```java\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        int n = parents.length; // no. of nodes\n        \n        //for stor
```java\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        int n = parents.length; // no. of nodes\n        \n        //for storing left and right child of each node\n        ArrayList<Integer>[] a = new ArrayList[n];\n        \n        for(int i=0;i<n;i++)\n            a[i]=new ArrayList<Integer>();\n        \n        for(int i=1;i<n;i++)\n            a[parents[i]].add(i);\n        \n        //store total number of children of each node\n        int[] child = new int[n]; \n        Arrays.fill(child,-1);\n        \n        dfs(0,a,child); //calculating all childrens at each node\n    \n        //storing scores of each node\n        long[] scores = new long[a.length];\n        \n        long maxScore=0; //maxScore\n        \n        for(int i=0;i<n;i++)\n        {\n            long res=1; // calculating score for a particular node\n            for(int y:a[i])\n                res*=child[y]+1;\n            \n            res*=Math.max(1,n-child[i]-1);\n            scores[i]=res;\n            if(res>maxScore)\n                maxScore=res;\n        }\n    \n        int c=0; // count of maxScores\n        for(long score:scores)\n            if(score==maxScore)\n                c++;\n        \n        return c;\n    }\n    \n    private int dfs(int x,ArrayList<Integer>[] a,int[] child)\n    {\n        int c=0;\n        for(int y:a[x])\n            c+=dfs(y,a,child);\n\n        return child[x]=c+a[x].size();\n    }\n}
[]