Given a directed weighted graph represented by an adjacency list, where nodes are indexed from 0 to N-1, determine the shortest path distance from a source node `src` to a target node `dst`. Each edge has a non-negative weight. If no path exists between the source and the target, return -1.
Explanation: The path 0 -> 1 -> 2 results in a total weight of 15, which is less than the direct path of 20.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak