← All mock interviewsHints used: 0
Course Schedule Mock Interview
- ✓Problem→
- 2Clarifying Questions→
- 3Constraints→
- 4Brute Force→
- 5Complexity Analysis→
- 6Pattern Recognition→
- 7Optimized Solution→
- 8Implementation→
- 9Testing→
- 10Follow-Up→
- 11Evaluation
Problem
There are numCourses courses labelled 0 … numCourses - 1. You are given a list prerequisites where [a, b] means you must take course b before course a. Return true if it is possible to finish all courses, and false otherwise.
Constraints
- 1 ≤ numCourses ≤ 10^5
- 0 ≤ prerequisites.length ≤ 5·10^3
- all pairs [a, b] are distinct
Example
in: numCourses = 2, prerequisites = [[1,0]]
out: true
Clarify
Before choosing anything: what would you ask the interviewer? What assumptions are you making? (Duplicates? Empty input? Value ranges? What to return when there is no answer?)