You are given an undirected tree rooted at node n nodes numbered from n edges of length n edges[i]
You are also given a colors of length n, where colors[i] denotes the color assigned to node i.
A subtree rooted at a node u consists of node u and all of its descendants. A subtree is said to have the same color if every node in the subtree shares the exact same color.
Return the maximum size of a subtree where all nodes have the same color.
Constraints:
n edges.length
n
edges[i]
n
colors.length n
colors[i]
The input is generated such that the graph represented by edges is a tree.
You are given an undirected tree rooted at node n nodes numbered from n edges of length n edges[i]
You are also given a colors of length n, where colors[i] denotes the color assigned to node i.
A subtree rooted at a node u consists of node u and all of its descendants. A subtree is said to have the same color if every node in the subtree shares the exact same color.
Return the maximum size of a subtree where all nodes have the same color.
Constraints:
n edges.length
n
edges[i]
n
colors.length n
colors[i]
The input is generated such that the graph represented by edges is a tree.