You are given an integer n representing the number of nodes in a tree rooted at node n edges of size n edges[i]
Each node is assigned a character label, given as a string labels where labels[i] is the label of node
Return an array ans of size n, where ans[i] is the number of nodes in the subtree of node
Note: The subtree of a node
consists of node itself along with all of its descendant nodes in the rooted tree.
Constraints:
n
edges.length n
edges[i].length
n
labels.length n
labels consists only of lowercase English letters.
You are given an integer n representing the number of nodes in a tree rooted at node n edges of size n edges[i]
Each node is assigned a character label, given as a string labels where labels[i] is the label of node
Return an array ans of size n, where ans[i] is the number of nodes in the subtree of node
Note: The subtree of a node
consists of node itself along with all of its descendant nodes in the rooted tree.
Constraints:
n
edges.length n
edges[i].length
n
labels.length n
labels consists only of lowercase English letters.