FastPrepCritical Path Through Dependent Tasks
Problems/Critical Path Through Dependent Tasks

Critical Path Through Dependent Tasks

Modular logoModular● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two firsthand Modular reports describe the same scheduling exercise. Tasks have dependencies and durations. The candidate must find both the longest critical-path value and the critical path itself. One report gives six example DAGs. The reports leave out the function signature and the tie rule. So we chose the array interface and a rule that ties go to the lexicographically smaller path.

Our version is about 89% the same as the reported question.

Each task has a unique name, a positive duration, and zero or more prerequisite task names. The dependencies form a directed acyclic graph.

Return a string array whose first value is the maximum total duration of any dependency path and whose remaining values are the task names on that path in execution order. If several paths have the same maximum duration, return the lexicographically smallest task-name sequence.

Function

criticalPathSchedule(taskNames: String[], dependencies: String[][], durations: int[]) → String[]

Examples

Example 1

taskNames = ["A","B","C"]dependencies = [[],[],["A"]]durations = [3,5,5]return = ["8","A","C"]

The dependent path A to C lasts 8, longer than standalone B.

Example 2

taskNames = ["A","B","C","D","E"]dependencies = [[],["A"],["A"],["B","C"],["D"]]durations = [3,2,7,4,2]return = ["16","A","C","D","E"]

The longer branch into D passes through C.

Example 3

taskNames = ["A","B"]dependencies = [[],[]]durations = [4,4]return = ["4","A"]

Equal standalone paths use the lexicographically smaller sequence.

Constraints

  • 1 <= taskNames.length == dependencies.length == durations.length <= 200.
  • Task names are unique nonempty ASCII strings.
  • Every dependency names another task, and the graph is acyclic.
  • 1 <= durations[i] <= 100000; every path total fits a signed 32-bit integer.

More Modular Phone Screen questions

  • Dense Matrix MultiplicationPHONE SCREEN · Seen Nov 2023

Similar questions at other companies

  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Minimum Completion Time for DAG DependenciesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Work Order Critical PathHadrian · PHONE SCREENHadrian interview questions
  • Longest Name Chain in a Directed Acyclic GraphOscar Health · PHONE SCREEN
  • Service Dependency Load FactorsRobinhood · PHONE SCREENRobinhood interview questions
  • Minimum Time to Complete Target CoursesMeta · ONSITE INTERVIEWMeta interview questions
  • Longest Chain BookingAirbnb · PHONE SCREENAirbnb interview questions
  • Earliest Dataset Readiness in a PipelinexAI · PHONE SCREENxAI interview questions
  • Longest Path in a Directed Acyclic GraphSuno · PHONE SCREEN
  • Parallel Courses IIISnowflake · ONSITE INTERVIEWSnowflake interview questions
See Modular hiring insights
Saved
class Solution {
    public String[] criticalPathSchedule(String[] taskNames, String[][] dependencies, int[] durations) {
        // Return {totalDuration, firstTask, ..., lastTask}.
    }
}
Checking account…