Nodes lying on Same Path in Trees

56 Views Asked by At

Given a Treen with $n$ nodes and $n-1$ edges, I have to answer $Q$ queries. In every query, I get a list of nodes of size $k$, $n_1, n_2, ..., n_k$. I need to answer the minimum number of paths that are required that cover all of these nodes.See the example for better insight