FastPrepMinimum Completion Time for DAG Dependencies
Problems/Minimum Completion Time for DAG Dependencies

Minimum Completion Time for DAG Dependencies

Amazon logoAmazon● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Amazon onsite interviews for new grad and full-time roles. The reports ask for the least time to finish tasks that have prerequisites, where any number of tasks can run at the same time. We added the function signature, the examples, and the limits. Our version is about 90% the same as the reported question.

You are given a list of tasks. durations[i] is how long task i takes, and every duration is positive. Each pair [before,after] in dependencies means task after may start only after task before finishes.

The dependencies form a DAG (a directed acyclic graph): if you follow them from task to task, you never come back to a task you already passed.

A task is available once every task it depends on has finished. Any number of available tasks can run at the same time. Return the minimum time needed to finish every task.

Function

minimumCompletionTime(durations: int[], dependencies: int[][]) → long

Examples

Example 1

durations = [3,2,5]dependencies = [[0,2],[1,2]]return = 8

Tasks 0 and 1 have no dependencies, so both start right away. The last task needs both of them, and the slower one ends at time three. Task 2 then runs and finishes at time 8, which is the answer.

Example 2

durations = [2,4,3,7]dependencies = [[0,1],[0,2]]return = 7

The last task has no dependencies, so it starts right away and runs for seven units. Every other task is done before that, so the minimum time is seven.

Example 3

durations = []dependencies = []return = 0

There are no tasks, so no time is needed. The answer is zero.

Constraints

  • 0 <= durations.length <= 100000.
  • 1 <= durations[i] <= 10^9.
  • The dependency graph is a DAG.

More Amazon Onsite Interview questions

  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • 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
  • Critical Path Through Dependent TasksModular · PHONE SCREEN · ONSITE INTERVIEW
  • 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

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public long minimumCompletionTime(int[] durations, int[][] dependencies) {
        // write your code here
    }
}
Checking account…