You are given a parents of length n, representing a binary tree rooted at node parents[i] is the parent of node i. Since node parents[0] is
Each node has a score. To compute the score of a node:
Remove the node and all of its connected edges from the tree.
The remaining nodes will form one or more non empty subtrees.
The score of the node is the product of the sizes of all these remaining subtrees. If there are no remaining subtrees, the score is
Return the number of nodes that achieve the maximum possible score.
Constraints:
n parents.length
n
parents[0]
parents[i] n i
parents represents a valid binary tree.
You are given a parents of length n, representing a binary tree rooted at node parents[i] is the parent of node i. Since node parents[0] is
Each node has a score. To compute the score of a node:
Remove the node and all of its connected edges from the tree.
The remaining nodes will form one or more non empty subtrees.
The score of the node is the product of the sizes of all these remaining subtrees. If there are no remaining subtrees, the score is
Return the number of nodes that achieve the maximum possible score.
Constraints:
n parents.length
n
parents[0]
parents[i] n i
parents represents a valid binary tree.