Easy Java Solution With Comments
\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        //--build tree start--\n        Node[] arr = new Node[parents.length];\n    
```\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        //--build tree start--\n        Node[] arr = new Node[parents.length];\n        for(int i = 0;i<parents.length;i++)\n            arr[i] = new Node();\n        \n        for(int i = 1;i<parents.length;i++){\n            arr[i].parent = arr[parents[i]];\n            arr[i].id = i;\n            if(arr[parents[i]].left==null){\n                arr[parents[i]].left = arr[i];\n            }else\n                arr[parents[i]].right = arr[i];\n        }\n        // --build tree complete---\n        \n        countLeftAndRightScoreNodes(arr[0]);// build node\'s left and right count maps\n\n        for(Node node: arr){//calculate product of all subtrees for given node\n            long parentSide = 1, rightSide = rcMap.getOrDefault(node.id,0), leftSide = lcMap.getOrDefault(node.id,0);\n            parentSide = (rcMap.getOrDefault(0,0)+lcMap.getOrDefault(0,0)+1) - (rightSide+leftSide+1); // root\'s left count + root\'s right count - (current node and below count)\n            long product = Math.max(parentSide,1)*Math.max(rightSide,1)*Math.max(leftSide,1);\n            tm.put(product,tm.getOrDefault(product, 0)+1);\n        }\n        return tm.get(tm.lastKey());\n    }\n    \n    TreeMap<Long, Integer> tm = new TreeMap<>();\n    Map<Integer,Integer> lcMap = new HashMap<>();//left count\n    Map<Integer,Integer> rcMap = new HashMap<>();\n\n    void countLeftAndRightScoreNodes(Node root){//post order traversal to build left and right node counts\n        if(root == null)\n            return;\n        countLeftAndRightScoreNodes(root.left);\n        countLeftAndRightScoreNodes(root.right);\n\n        int currentCount = (root.left!=null?lcMap.getOrDefault(root.id,0):0)+(root.right!=null?rcMap.getOrDefault(root.id,0):0)+1;\n        if(root.parent==null)\n            return;\n        if(root==root.parent.left){\n            lcMap.put(root.parent.id,currentCount);\n        }else{\n            rcMap.put(root.parent.id,currentCount);\n        }\n    }\n   \n}\nclass Node{\n    Node left;\n    Node right;\n    Node parent;\n    int id = 0;//index\n    public Node(){\n    }\n    public Node(Node left, Node right, Node parent){\n        this.left = left;\n        this.right = right;\n        this.parent = parent;\n    }\n}\n```
[]