FastPrepMinimum Time to Complete Target Courses
Problems/Minimum Time to Complete Target Courses

Minimum Time to Complete Target Courses

Meta logoMeta● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta onsite interview. The original report gives course lengths, prerequisites, target courses and a goal of the least time. It leaves out the scheduling rules and when the graph is valid. Here, courses can run in parallel and there are no cycles. Our version is about 88% the same as the reported question.

There are n courses labeled from 0 through n - 1. Course i takes durations[i] time units.

Each pair [course, prerequisite] in prerequisites means the prerequisite must finish before the course can start. The prerequisite graph is acyclic.

You may take any number of available courses in parallel. Return the minimum time needed to finish every course in targets, including every transitive prerequisite needed by those targets. Courses outside that required closure do not affect the answer.

Function

minimumTimeForTargets(durations: int[], prerequisites: int[][], targets: int[]) → long

Examples

Example 1

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

Courses 0 and 1 run in parallel. Course 2 starts at time 3 and finishes at time 8.

Example 2

durations = [2,4,3,7]prerequisites = [[1,0],[2,0]]targets = [1,2]return = 6

After course 0 finishes at time 2, courses 1 and 2 run together. The slower target finishes at time 6. Disconnected course 3 is irrelevant.

Example 3

durations = [5,1,2]prerequisites = []targets = [1,2]return = 2

With no prerequisites, both targets start immediately and the later one finishes after 2 time units.

Constraints

  • 1 <= durations.length <= 100000.
  • 1 <= durations[i] <= 10^9.
  • 0 <= prerequisites.length <= 200000.
  • Every prerequisite pair contains distinct valid course labels, all pairs are unique, and the graph is acyclic.
  • 1 <= targets.length <= durations.length, and target labels are unique.
  • The answer fits a signed 64-bit integer.

More Meta Onsite Interview questions

  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Minimum Completion Time for DAG DependenciesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Critical Path Through Dependent TasksModular · PHONE SCREEN · ONSITE INTERVIEW
  • Parallel Courses IIISnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Parallel Courses IIIGoogle · ONSITE INTERVIEWGoogle interview questions
  • 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
  • Longest Chain BookingAirbnb · PHONE SCREENAirbnb interview questions
  • Earliest Dataset Readiness in a PipelinexAI · PHONE SCREENxAI interview questions

Interview reports that mention this question

  • Meta Software Engineer Onsite Questions: 3 Experiences

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public long minimumTimeForTargets(int[] durations, int[][] prerequisites, int[] targets) {
        // Write your code here.
    }
}
Checking account…