There are a total of numCourses courses. You are given an array prerequisites. Return true if you can finish all courses.
Example 1
Input: numCourses = 6, prerequisites = [[1,0],[2,0],[3,1],[3,2],[4,3],[5,4]]
Output: true
Explanation: The prerequisites form a chain with no cycles: 0 unlocks 1 and 2, both unlock 3, then 3 → 4 → 5. Taking the courses in order 0, 1, 2, 3, 4, 5 finishes all of them.
Example 2
Input: numCourses = 2, prerequisites = [[1,0]]
Output: true
Explanation: Course 1 requires course 0. Take course 0 first and then course 1.
Example 3
Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
Output: false
Explanation: Course 1 requires course 0, and course 0 requires course 1. Neither can be taken first, so it is impossible to finish.
We can take all courses iff the prerequisite graph has no cycles. The clean way to detect cycles in a directed graph during DFS is the **three-colour** scheme: every node is `WHITE` (unvisited), `GRAY` (on the current DFS path), or `BLACK` (fully explored). If DFS ever steps onto a `GRAY` node, we've found a back-edge — a cycle.
Run checks all cases above. Submit evaluates all test cases.