given a weighted tree with n vertices. there are q queries and for each query, you are given integers (u,k). find number of vertices v such that the smallest edge on the route from u to v is equal to k. (n,q <= 1e5)
i tried using dfs but the best solution i could think is O(n*q)
New contributor
turtle silver is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.