# Course Schedule

Last Updated: 10 Jul, 2023
Easy
0/40
15 mins
85 %
+16 more

## Problem Statement

#### Note: There are no duplicate pairs in the prerequisites array.

##### For example-
``````If N = 2 and prerequisite = [[1, 2]]. Then, there are a total of 2 courses you need to take. To take course 1 you need to finish course 2. So, it is possible to complete all courses.
``````
Detailed explanation ( Input/output format, Notes, Images )
##### Constraints:
``````1 <= T <= 10
1 <= N <= 5000
0 <= M <= min(5000, (N * (N - 1)) / 2)
1 <= prerequisites[i][0] <= N
1 <= prerequisites[i][1] <= N

Time Limit: 1 sec
``````
##### Sample Input 1:
``````1
3 2
1 2
2 1
``````
##### Sample output 1:
``````No
``````
##### Explanation of Sample output 1:
``````There are a total of 3 courses you need to take. To take course 1 you need to finish course 2. To take course 2 you need to finish course 1. So, it is impossible to complete all courses.
``````
##### Sample Input 2:
``````2
4 0
4 2
1 2
2 3
``````
##### Sample output 2:
``````Yes
Yes
``````
Autocomplete
Console