you have been given tree, find a shortest path to travel from 1 to N, such that you visits some given set of nodes in your path from 1 to N. you are allowed to visit same node multiple times.
eg — N = 5
1
/ \
2 3
/ \
4 5
CONSTRAINTS — N UPTO ( 1e5 )
node_to_visit_in_path = { 2 ,4 } solution — 6 ( 1 -> 2 -> 1 -> 3 -> 4 -> 3 -> 5)
is this a famous kind of problem ?, i think similar problem i have see somewhere.