You are given a catalog of training courses. Each course has:
course_id
prereqs
(possibly empty)
Write a function isValidCatalog(courses) -> bool that validates the catalog.
A catalog is considered valid if:
Follow-ups (discuss, no need to implement unless asked):
Example:
A: [B, C]
,
B: [C]
,
C: []
-> valid
A: [B]
,
B: [A]
-> invalid (cycle)
A: [X]
where
X
not in catalog -> invalid