Benny and Some Magic - DFS problem


I am trying to solve this problem which asks to find a path in a directed graph, so that difference between maximum weight edge on the path and minimum weight edge on the path is maximum possible.

How do I approach this problem ? I find it difficult to understand from the editorial

Link :-

Thanks !!