All Paths From Source to Target | Leet code 797 | Theory explained + Python code

preview_player
Показать описание
This video is a solution to Leet code 797, All Paths From Source to Target. I first give a theoretical explanation and then I go over its Python implementation.

Comment below if you have a better solution to this problem!

Let me know if you have any feedback and don't forget to subscribe for more videos!

Gear used:
Рекомендации по теме
Комментарии
Автор

instead of going from source to destination, can't we go from destination to source where we save what route is used till that node and append it to the previous.

for eg. in the above example, we travel from node 3. then we go to node 2(it goes to 3) so we save that to node 2. Then we go to node 1, and it goes to 3 as well so we save that as a route. then then we go to node 0, first it goes to 1 so we add route of 1 and for 2, we add route of 2

jheelgala
Автор

Thanks, man!
A couldn't understand a long time input of problem before i have watched that video (:

dmitryromashov
Автор

I think it could be solved with just .pop()

Any particular reason to pop from left pop(0)
?

Ankit-hsnb
Автор

Hi can you please solve Possible Bipartition problem from leetcode numbered 886?

pallavijorapur
Автор

Write a function find_all_routes to display all possible routes from senders location to receivers location given in the dictionary for each shipment.¶

Graph data structure is used to represent network of pickup and delivery nodes. Consider a below graph diagram for given nodes in the table where sender location and receiver location is represented by node with number.
Connection between two nodes shows route exists between those areas. E.g there exists a path from area 1 to area 2 but there is no direct route between area1 and area5. please note that this routes are bidirectional.
To reach to area5 from area1, delivery person can take any route like 1-2-4-5 or 1-2-3-4-5

can you help with this?

varshagoel
welcome to shbcf.ru