# Topological Sort

## Метаданные

- **Канал:** NeetCode
- **YouTube:** https://www.youtube.com/watch?v=mw1Z99JZ048

## Содержание

### [0:00](https://www.youtube.com/watch?v=mw1Z99JZ048) Segment 1 (00:00 - 01:00)

now let's solve course schedule we're given a bunch of pairs of courses so for example before we can take course B we have to take course a first and maybe before we can take course C we also have to take course a first but before we can take course D we have to take C and we have to take B is it possible for us to take every single course in this example it is we first start out with course a but after a we can then take either this one or this one and then after we take both of them we can then take d add a line from D back to a it is now no longer possible so this problem is all about cycle detection is just building an adjacency list we're given the edges and we want to convert it into a graph then after that we're going to initialize a q for our breath for search we're only going to add the nodes that don't have any prerequisites after that we do a basic bread for search down here

---
*Источник: https://ekstraktznaniy.ru/video/20700*