Leetcode 1203 Sort Items by Groups Respecting Dependencies

Sdílet
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.

Komentáře • 11

  • @sahilverma1991
    @sahilverma1991 Před 11 měsíci +1

    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

  • @rishabhtiwari1752
    @rishabhtiwari1752 Před 11 měsíci +1

    thnx u made it an easy problem

  • @leepakshiyadav1643
    @leepakshiyadav1643 Před 11 měsíci +1

    Thanks a lot, you made it easier to understand :)

  • @user-fu4mw8no5t
    @user-fu4mw8no5t Před 11 měsíci +1

    great explanation

  • @coderhumai
    @coderhumai Před 11 měsíci +1

    thank you sir

    • @c0de_sutra
      @c0de_sutra  Před 11 měsíci

      Most welcome! I am happy that you liked it!!

  • @avinashchaurasiya6497
    @avinashchaurasiya6497 Před 11 měsíci +1

    Can u pls explain what is the use of toposort in items graph,
    is it for finding cycles?

    • @c0de_sutra
      @c0de_sutra  Před 11 měsíci

      It's to find the order of task. Eg course scheduling in college.

  • @c0de_sutra
    @c0de_sutra  Před 11 měsíci

    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/