TreeNode + PostOrder to calculate left and right subtree sums
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python []\nclass TreeNode:\n    def __init__(self, val):\n        self.val = val\n        self.left = None\n        self.right = None\n        self.leftSize = 0\n        self.rightSize = 0\n        \nclass Solution(object):\n    def countHighestScoreNodes(self, parents):\n        """\n        :type parents: List[int]\n        :rtype: int\n        """\n\n        n = len(parents)\n        val_to_node = {i:TreeNode(i) for i in range(n)}\n\n        # build tree\n        for c, p in enumerate(parents):\n            if c != 0:\n                parent = val_to_node[p]\n                child = val_to_node[c]\n                if not parent.left:\n                    parent.left = child\n                else:\n                    parent.right = child\n\n        def postOrder(node): # returns Size of subtress where we store in the nodes\n            if node is None:\n                return 0\n            node.leftSize = postOrder(node.left)\n            node.rightSize = postOrder(node.right)\n            return 1 + node.leftSize + node.rightSize\n        postOrder(val_to_node[0])\n        \n        score_to_number = defaultdict(int)\n        highest_score = float("-inf")\n        for i in range(n):\n            node = val_to_node[i]\n            left, right = node.leftSize, node.rightSize\n            remaining = max(1, n - left - right - 1)\n            score =  max(1,left)*max(1,right)*remaining\n            score_to_number[score] += 1\n            highest_score = max(highest_score, score)\n        return score_to_number[highest_score]                    \n```
['Python']