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