How to print shortest path from source node to destination node?

I got the concept explained in the video “Single Source Shortest Path”
Link to code explained in video-> https://ide.codingblocks.com/s/485153

But in the video, he printed shortest dist of each node for eg: shortest dist of 5 is 3
Instead, I want to print shortest path from source to destination. i.e. for eg: if source =3 & destination = 5
then. shortest path is 3->4->5 and I want to print that.
How can I do that? Please help

hello @ikshuldureja130

simply maintain one parent arry that will keep track of parent of each node.
and then use it to iterate from destination to source and print the path.

Can you please check out the code in the link-> https://ide.codingblocks.com/s/485153

It is giving time limit exceeded error

in line 41 , it should be ==

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.