Prerequisites
Medium
Given an integer n representing the number of courses labeled from 0 to n - 1, and an array of prerequisite pairs, determine if it's possible to enroll in all courses.
Each prerequisite is represented as a pair [a, b], indicating that course a must be taken before course b.
Example:
Input: n = 3, prerequisites = [[0, 1], [1, 2], [2, 1]]
Output: False
Explanation: Course 1 cannot be taken without first completing course 2 and, and vice versa.
Constraints:
- For any prerequisite
[a, b],awill not equalb.