Cheapest Flights Within K Stops | Bellman Ford Algorithm Python Solution

Опубликовано: 12 Апрель 2022
на канале: Emily Bao
332
10

Link to Question:
https://leetcode.com/problems/cheapes...

The reason why we have 2 price lists, instead of updating everything real time is to keep the BFS structure by going level by level, otherwise if everything is updated in one go, K steps would still be at 0

Time Complexity: O(E*K)

Space Complexity: O(V) occupied by two price lists