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
Automate a Common Deployment Task
00:00
5 left

Automate a Common Deployment Task

MediumPython

Problem

Nielsen ONE deployments may contain services that depend on other services being deployed first. Given a set of services and prerequisite relationships, generate the deployment waves that respect every dependency while allowing independent services to deploy together.

A dependency [service, prerequisite] means the prerequisite must appear in an earlier wave than the service. Within each wave, return service names in lexicographic order. Return an empty list if the dependencies contain a cycle, because no valid deployment plan exists.

Formal Specification

Implement deploy_waves(services, dependencies).

  • services is a list of unique strings.
  • dependencies is a list of two-element lists, each containing a service and one of its prerequisites.
  • Return a list of lists of strings. Each inner list is one deployment wave.
  • Every service must appear exactly once in the result when the dependency graph is acyclic.
  • Services with no unmet prerequisites may be placed in the same wave.

Constraints

  • 1 <= len(services) <= 10^5
  • 0 <= len(dependencies) <= 2 * 10^5
  • Service names are unique, non-empty strings
  • Every dependency references a service in services
  • Duplicate dependency pairs do not appear

Function Signature

def deploy_waves(services, dependencies):
Interviewer

Your question is Automate a Common Deployment Task. 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.