Leetcode 1203 Sort Items by Groups Respecting Dependencies
Vložit
- čas přidán 18. 08. 2023
- Telegram Link:
t.me/+FieKB7Ds6j02Y2Y1
t.me/+JU-ZF-oDjX4xYjBl
Problem Link: leetcode.com/problems/sort-it...
Solution Link: leetcode.com/problems/sort-it...
Sort Items by Groups Respecting Dependencies is leetcode 1489 and we are using Topological Sort to solve this problem.
Use a queue for topological sort. For topological sort a stack will work because we push into stack only when the indegree is 0. However for BFS we need to use a queue. Thus the solution can be confusing for beginners
thnx u made it an easy problem
Thanks a lot, you made it easier to understand :)
You are welcome!
great explanation
Thank you!!
thank you sir
Most welcome! I am happy that you liked it!!
Can u pls explain what is the use of toposort in items graph,
is it for finding cycles?
It's to find the order of task. Eg course scheduling in college.
Similar problems and Telegram Link:
t.me/+FieKB7Ds6j02Y2Y1
t.me/+JU-ZF-oDjX4xYjBl
leetcode.com/problems/course-schedule/
leetcode.com/problems/course-schedule-ii/
leetcode.com/problems/find-eventual-safe-states/