[Python] DFS Solution with Dictionary, Straightforward, No Zip
Runtime: 1816 ms, faster than 83.52% of Python3 online submissions for Count Nodes With the Highest Score.\nMemory Usage: 112.2 MB, less than 76.78% of Python3 
*Runtime: 1816 ms, faster than 83.52% of Python3 online submissions for Count Nodes With the Highest Score.\nMemory Usage: 112.2 MB, less than 76.78% of Python3 online submissions for Count Nodes With the Highest Score.*\n\nMy solution is never fancy but it must be straightforward and understandable (hopefully).\n1. Create a dictionary of {parent node : its son nodes}\n2. Do a dfs search to find out the size of each node, save the results\n3. Calculate the score for each node (assume it\'s removed), record the frequency of each score in another dictionary, also record the max score.\n\n\n```\nclass Solution:\n    def countHighestScoreNodes(self, parents: List[int]) -> int:\n        n = len(parents)\n        \n        dic = {} # parent : sons\n        for i in range(n):\n            if parents[i] not in dic:\n                dic[parents[i]] = []\n            dic[parents[i]].append(i)\n        \n        # dfs search the size of each node (number of subtrees + node itself)\n        # save the result in tree_size\n        tree_size = [0 for i in range(n)]\n        def search(root: int):\n            root_size = 1\n            if root in dic: # if root is a parent\n                for son in dic[root]:\n                    son_size = search(son)\n                    root_size += son_size\n            \n            tree_size[root] = root_size\n            return root_size\n        \n\t\t# search the root\n        search(0)\n        \n        max_score = 0\n        freq = {}\n        for i in range(n):\n\t\t\t# initialization: if i is not a parent\n            left_size = 0\n            right_size = 0\n            \n            if i in dic: # if i is a parent\n                if len(dic[i]) > 0:\n                    left_size = tree_size[dic[i][0]] # size of its left subtree\n                if len(dic[i]) > 1:\n                    right_size = tree_size[dic[i][1]] # size of its right subtree\n                    \n            # score = size of left subtree * size of right subtree * size the other trees (except i which is removed)\n            score = max(left_size, 1) * max(right_size, 1) * max(n - 1 - left_size - right_size, 1)\n            \n            if score not in freq:\n                freq[score] = 0\n            freq[score] += 1\n            max_score = max(max_score, score)\n            \n        return freq[max_score]\n```\n\nSome of the master solutions in discussion are too fancy for me to understand (as I only know basic functions), so I made my own.\nHope it can help! ( \u2022\u0300 \u03C9 \u2022\u0301 )y
['Depth-First Search', 'Python', 'Python3']