← Games

🧮 DSA Algorithm Visualizer

Graph Problems
BFS
Topological Sort
Union-Find
DFS
DP
Heap
Binary Search
LC #207Cycle Detection

Course Schedule I

There are numCourses courses labeled 0 to numCourses-1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates you must take course bi before course ai. Return true if you can finish all courses.

Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
Output: true

Problem

Read the problem statement. Understand input/output format and constraints. Each problem uses graph algorithms.

1/7

Algorithm Pattern

  1. Build adjacency list + in-degrees
  2. Enqueue all in-degree 0 nodes
  3. BFS: dequeue → result → reduce neighbors
  4. If neighbor reaches 0 → enqueue
  5. Check if all nodes processed