Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Task Execution Engine
00:00
5 left

Task Execution Engine

HardPython

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 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):
Interviewer

Your question is Task Execution Engine. Start with the requirements in the Question tab.

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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.