Quote:I will really appreciate it if you solve this problem with C++

**Do you understand that you are basically required to create a solution by- yourself ?**

And not necessarily the optimum algorithm.

And not necessarily the optimum algorithm.

Quote:Someone said to me that the problem can be solved with simple Dijkstra Search, but I don't see how the shortest path between two nodes can solve this problem.

As far as I understand, it is not "Dijkstra shortest path" algorithm.

thendo what I suggested, I think you'll find the same walk as if you applied my suggestion to the entire graph.