77. Possible Courses
Medium
There are total courses numbered from 0 to total - 1. Each pair [curso, requisito] indicates that the requirement must be completed before the course. Return true if it is possible to complete all courses.
Example 1
Input: total = 4, requisitos = [[1,0],[2,1],[3,2]]
Output: true
Example 2
Input: total = 2, requisitos = [[1,0],[0,1]]
Output: false
Constraints
- 0 <= total <= 2000
- 0 <= requisitos.length <= 5000
- The course indices are valid.
GraphsBFSDFS
Saved in this browser
Caso 1
total =
4
requisitos =
[[1,0],[2,1],[3,2]]
Expected =
true
Caso 2
total =
2
requisitos =
[[1,0],[0,1]]
Expected =
false
Run checks these 2 cases. Submit runs all 6, including hidden ones.