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
Custom JUnit Implementation
00:00
5 left

Custom JUnit Implementation

HardPython

Problem

NTT DATA's workflow orchestration services execute tasks subject to dependency constraints. Given a set of uniquely identified tasks in a dependency graph, implement the functional code required by the custom JUnit tests to calculate when every task can finish and identify the workflow's critical path.

The dependency graph is guaranteed to be a directed acyclic graph for normal inputs. A task can start immediately after all listed dependencies finish, and unlimited parallel execution is allowed.

Formal Specification

Implement analyze_workflow(tasks). tasks is a list of objects containing:

  • id: a unique string task identifier
  • duration: a non-negative integer execution time
  • depends_on: a list of task identifiers

Return an object containing completion_times, a mapping from task ID to earliest completion time, makespan, the maximum completion time, and critical_path, the task sequence producing the makespan. If a cycle exists, return empty completion times, a makespan of -1, and an empty critical path. For tied critical paths, return the lexicographically smallest task sequence.

Constraints

  • 0 <= len(tasks) <= 10^5
  • Task IDs are unique strings
  • Every dependency references an existing task
  • 0 <= duration <= 10^9
  • The total number of dependency edges is at most 2 * 10^5
  • Normal inputs form a directed acyclic graph

Function Signature

def analyze_workflow(tasks):
Interviewer

Your question is Custom JUnit Implementation. 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.