Code and explanation: https://www.patreon.com/posts/23-usin...
Given an adjacency list for a Directed Acyclic Graph (DAG) where adj[u] contains a list of all vertices v such that there exists a directed edge u to v. Return topological sort for the given graph.
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u to v, vertex u comes before v in the ordering.
Note: As there are multiple Topological orders possible, you may return any of them. If your returned Topological sort is correct then the output will be 1 else 0.
Examples:
Input: adj = [[], [0], [0], [0]]
Output: 1
Explanation: The output 1 denotes that the order is valid. Few valid Topological orders for the given graph are:
[3, 2, 1, 0]
[1, 2, 3, 0]
[2, 3, 1, 0]
Link: https://www.geeksforgeeks.org/problem...
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:
🖊️ : My Pen (Used in videos too): https://amzn.to/38fKSM1
👨🏻💻 : My Apple Macbook pro: https://amzn.to/3w8iZh6
💻 : My gaming laptop: https://amzn.to/3yjcn23
📱 : My Ipad: https://amzn.to/39yEMGS
✏️ : My Apple Pencil: https://amzn.to/3kMnKYf
🎧 : My Headphones: https://amzn.to/3kMOzM7
💺 : My Chair: https://amzn.to/385weqR
🛋 : My Table: https://amzn.to/3TyU2IU
⏰ : My Clock: https://amzn.to/3slFUV3
🙋🏻♀️ : My girlfriend: https://amzn.to/3M6zLDK ¯\_(ツ)_/¯
PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Смотрите видео 23 TopologicalSort using DFS | Graph онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Aditya Verma 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 53 раз и оно понравилось 2 людям.