← 返回 bytedance 的题目列表Task Scheduling
类型:online_judge
Design a scheduling system to manage the execution order of tasks such that tasks with the shortest duration are executed first. Choose a data structure and algorithm to optimally support this requirement, allowing efficient task insertion and retrieval of the shortest duration task.
Example:
Task List: [ (Task A, 3), (Task B, 1), (Task C, 2) ] Output Order: [ Task B, Task C, Task A ]
Tasks can be represented as tuples where the second element is the task duration.
Example
Input
[(3, 'Task A'), (1, 'Task B'), (2, 'Task C')]