11015

 

208

 

459

This problem can be solved using dfs,bfs or union find algorithm, BFS solution:

 

10308

This is the problem to find the tree diameter.

 

11709

 

341

This problem can also be solved using Dijkstra’s algorithm. The one thing to keep in mind is to store the parent vertex of any vertex, so that we can reconstruct the path once we reached the target node. To remember the path, we can use a vector to store where I con from in some