← 返回 jpmorgan 的题目列表Course Schedule
类型:online_judge
Problem: Course Schedule
There are numCourses courses labeled from 0 to numCourses - 1. You are given an array prerequisites, where prerequisites[i] = [a, b] means you must take course b before course a.
Return whether it is possible to finish all courses.
Input Format
First line: integer numCourses
Second line: integer m, the number of prerequisite pairs
Next m lines: two integers a b, meaning course b must be taken before course a
Output Format
Print true if all courses can be finished
Otherwise print false
Constraints
1 <= numCourses <= 2000
0 <= m <= 5000
0 <= a, b < numCourses
a != b
Example
Input:
2
1
1 0
Output:
true
Example
Input
2
1
1 0
Output
true