You are given an undirected weighted tree with n nodes labeled from 0 to n edges where edges[i] [u_i, v_i, w_i] represents an edge between nodes u_i and v_i with weight w_i.
You are also given an array queries where queries[j] [u_j, v_j].
For each query [u_j, v_j], consider the unique simple path starting from u_j and ending at v_j. Let the sum of all edge weights along this path be u_j to v_j such that the sum of edge weights from u_j to
Return an array of integers containing the answer for each query.
Constraints:
n
edges.length == n - 1
edges[i] == [u_i, v_i, w_i]
u_i, v_i n
w_i
queries.length
queries[j] == [u_j, v_j]
u_j, v_j n
The input is generated such that edges represents a valid tree.
You are given an undirected weighted tree with n nodes labeled from 0 to n edges where edges[i] [u_i, v_i, w_i] represents an edge between nodes u_i and v_i with weight w_i.
You are also given an array queries where queries[j] [u_j, v_j].
For each query [u_j, v_j], consider the unique simple path starting from u_j and ending at v_j. Let the sum of all edge weights along this path be u_j to v_j such that the sum of edge weights from u_j to
Return an array of integers containing the answer for each query.
Constraints:
n
edges.length == n - 1
edges[i] == [u_i, v_i, w_i]
u_i, v_i n
w_i
queries.length
queries[j] == [u_j, v_j]
u_j, v_j n
The input is generated such that edges represents a valid tree.