Medium · Graphs
Course Schedule
You are given a number of courses, numbered from 0, and a list of pairs [a, b] meaning course b must be taken before course a. Return whether every course can be finished.
- It is impossible only when the requirements go round in a circle.
- A course can have several requirements, or none.
- No pair is listed twice.
courses = 2 needs = [[1, 0]] → true (take 0, then 1)Record your take