16.3 Tasks Scheduling (medium)
Problem Statement
Input:
Tasks=3,
Prerequisites=[0, 1], [1, 2]
Output: true
Explanation: To execute task '1', task '0' needs to finish first.
Similarly, task '1' needs to finish before '2' can be scheduled.
A possible sceduling of tasks is: [0, 1, 2] Input:
Tasks=3,
Prerequisites=[0, 1], [1, 2], [2, 0]
Output: false
Explanation: The tasks have cyclic dependency,
therefore they cannot be sceduled.Input:
Tasks=6,
Prerequisites=[2, 5], [0, 5], [0, 4], [1, 4], [3, 2], [1, 3]
Output: true
Explanation: A possible sceduling of tasks is: [0 1 4 3 2 5] Solution
Last updated