Skip to main content
← CoursesInterview PrepModule 3 · Trees, Graphs, BFS/DFSGraphs: Dijkstra shortest pathwrite46 / 100
💬 Discuss🧪 Playground+150 XP
Task
📝 **Question:** Implement `dijkstra(graph, src)` returning the dict of shortest distances. Graph format: `{node: [(neighbor, weight), ...]}`. Run on `{'A':[('B',1),('C',4)],'B':[('C',2),('D',5)],'C':[('D',1)],'D':[]}` from 'A'. Print result sorted by key. 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…