Graphs pattern

Course Schedule

Given a number of courses and a list of prerequisite pairs, determine whether it is possible to finish all courses (i.e. the prerequisite graph contains no cycle). Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 207
  • 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 207

Medium

The approach

  1. 01 Kahn's algorithm (topological sort by in-degree) 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 and spot the graphs pattern in it
  • Kahn's algorithm (topological sort by in-degree): 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 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.