Network Delay Time (Djikstra's Algorithm) - Leetcode 743 - Graphs (Python)

preview_player
Показать описание


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

two things i did differently in my implementation. 1. I used a visited set and didn't need the min times dict. You can just store the max time any time a new node is added to the visited set. Since we are using a heap, we are guaranteed that the node popped off the heap first, if it is not visited, is the lowest cost unvisited node. 2. You don't need to check whether the neighbors are in min times, since if they were, you are anyway skipping those nodes with the earlier if condition. So that second check would be redundant.

shxdow
Автор

heapq is doing a lot of heavy lifting for us here

jmgpqcx
Автор

Should we not update the cost to reach a node even if it is already in min_times because a different path may give a lesser cost/time? Please help.

mehraan
Автор

Can we solve this problem in prims algorithm??

aakashs
Автор

Great video once again, please create one for BellmanFord

chisomedoka
Автор

is ther eany similarity between the min heap in dijkstras, and the min heap used in prims mst algo?

Dcebox
Автор

Not your best explanation Greg, thanks a lot still :)

hyrax_attack
Автор

Heapq.heapify(min_heap) missing in code.

otheraccount
welcome to shbcf.ru