You are given two undirected trees with
You are given two edges1 of length edges2 of length edges1[i] = [a_i, b_i] denotes an edge between nodes a_i and b_i in the first tree, and edges2[i] = [u_i, v_i] denotes an edge between nodes u_i and v_i in the second tree. You are also given an integer k.
A node k.
For each node
Return an array answer of size answer[i] represents the maximum possible number of target nodes from node
Note: The distance between two nodes is defined as the number of edges on the path connecting them. A node is always a target to itself since the distance is
.
Constraints:
edges1.length
edges2.length
edges1[i].length edges2[i].length
edges1[i]
edges2[i]
The input is generated such that edges1 and edges2 represent valid trees.
You are given two undirected trees with
You are given two edges1 of length edges2 of length edges1[i] = [a_i, b_i] denotes an edge between nodes a_i and b_i in the first tree, and edges2[i] = [u_i, v_i] denotes an edge between nodes u_i and v_i in the second tree. You are also given an integer k.
A node k.
For each node
Return an array answer of size answer[i] represents the maximum possible number of target nodes from node
Note: The distance between two nodes is defined as the number of edges on the path connecting them. A node is always a target to itself since the distance is
.
Constraints:
edges1.length
edges2.length
edges1[i].length edges2[i].length
edges1[i]
edges2[i]
The input is generated such that edges1 and edges2 represent valid trees.