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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Deadline Scheduling Algorithm
00:00
5 left

Deadline Scheduling Algorithm

HardPython

Problem

A Thales TopSky mission-planning component has a set of available tasks. Each task requires exclusive processor time, has a completion deadline, and provides value only if completed by that deadline. Tasks are non-preemptive, all are available at time 0, and at most one task can run at a time.

Return the IDs of a subset of tasks that maximizes total value. The returned IDs must be in a valid execution order. If multiple optimal schedules exist, any one is acceptable.

Formal Specification

Implement schedule_tasks(tasks), where tasks is a list of dictionaries. Each dictionary contains:

  • id: a unique string
  • duration: a positive integer
  • deadline: a positive integer
  • value: a non-negative integer

Return a list of task IDs. A selected task is valid only when its cumulative completion time is at most its deadline. Tasks that cannot be completed by their deadlines may be omitted.

Constraints

  • 1 <= len(tasks) <= 100
  • 1 <= tasks[i]["duration"] <= 20,000
  • 1 <= tasks[i]["deadline"] <= 20,000
  • 0 <= tasks[i]["value"] <= 10^6
  • Task IDs are unique strings
  • All tasks are available at time 0

Function Signature

def schedule_tasks(tasks):
Interviewer

Your question is Deadline Scheduling Algorithm. 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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.