Graphs pattern

Course Schedule II

Given a number of courses and their prerequisite pairs, return an ordering in which all courses can be taken. If no valid ordering exists (the graph has a cycle), return an empty list. Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 210
  • Medium
  • 1 approach

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

GraphsLeetCode 210

Medium

The approach

  1. 01 Kahn's algorithm, collect the pop order O(V + E)O(V + E) space
Played step by step, with its time and space.

What you will learn

  • How to read Course Schedule II and spot the graphs pattern in it
  • Kahn's algorithm, collect the pop order: O(V + E) time, O(V + E) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Graphs

See Course Schedule II run, step by step

Sign in and this page opens on the animation, with all 9 Graphs problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.