← Back to all problems
Medium

Course Schedule

Updated Feb 24, 2026

Problem

Return true if all courses can be finished.

Constraints

1 <= numCourses <= 2000

Examples

Example 1

Input: {"numCourses": 2, "prerequisites": [[1, 0]]}
Output: true

Function Signature

def canFinish(self, numCourses: int, prerequisites: list[list[int]]) -> bool

How to Submit

Implement a Solution class with a canFinish method.

Your method will be called with the input parameters and should return the answer.