Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Task Execution Engine

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Task Execution Engine. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Design a Task Execution Engine that executes tasks based on dependency relationships while maximizing parallelism and minimizing worker idle time.

Asked in the Technical Screen stage. Implement an event-driven scheduler for a directed acyclic task graph.

Input and Output

Implement def execute_tasks(tasks, worker_count):. tasks is a dictionary mapping each task ID to an object with integer duration and a list of task IDs in dependencies. Return an object containing makespan and schedule, where each schedule entry has task, start, and end. Start all currently ready tasks whenever workers are available. Use lexicographic task ID order to break scheduling ties.

Constraints

  • The dependency graph is a directed acyclic graph.
  • 1 <= len(tasks) <= 10^4
  • 1 <= worker_count <= 10^4
  • 1 <= duration <= 10^6
  • Task IDs are unique strings.
  • Every dependency refers to a task in tasks.

Function Signature

def execute_tasks(tasks, worker_count):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output