There are numCourses courses labelled 0..numCourses - 1. Each pair [a, b] in prerequisites means course a must be taken before course b. The prerequisites contain no cycle.
Write checkIfPrerequisite(numCourses, prerequisites, queries). For each query [u, v], say whether u is a prerequisite of v, either directly or through a chain of prerequisites. Return an array of booleans, one per query, in the same order.
- A course is not a prerequisite of itself
- There can be many queries, so do the graph work once, not once per query