Parallel Courses III
Updated
Problem statement
There are n courses labeled from 1 through n. You are given prerequisite relations and the duration of every course.
Each relation [previous, next] means course previous must be completed before course next can start. Course i takes time[i - 1] months.
You may take any number of courses concurrently whenever all of their prerequisites are complete. Return the minimum number of months needed to complete every course.
Function
minimumTime(n: int, relations: int[][], time: int[]) → intExamples
Example 1
n = 3relations = [[1,3],[2,3]]time = [3,2,5]return = 8Courses 1 and 2 start together. Course 3 starts after month 3, when both prerequisites are complete, and finishes five months later at month 8.
Example 2
n = 5relations = [[1,5],[2,5],[3,5],[3,4],[4,5]]time = [1,2,3,4,5]return = 12The critical chain is course 3, then course 4, then course 5, with total duration 3 + 4 + 5 = 12.
Constraints
1 <= n <= 5 * 10^40 <= relations.length <= min(n * (n - 1) / 2, 5 * 10^4)- Every relation contains two distinct course labels between
1andn. - All relations are unique, and the prerequisite graph is acyclic.
time.length == n1 <= time[i] <= 10^4
More Snowflake interview questions
- Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026
- Sliding-Window Rate LimiterONSITE INTERVIEW · Seen Sep 2026
- Execute Tasks by PriorityONSITE INTERVIEW · Seen Aug 2026
- Priority Task Execution with Duplicate IDsONSITE INTERVIEW · Seen Aug 2026
- Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
- Merge Two Binary TreesPHONE SCREEN · Seen Nov 2026
- Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
- Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
- Safest Shortest Path Through a GridOA · Seen Nov 2026
Similar questions at other companies
- Minimum Semesters With Course CapacityAmazon · ONSITE INTERVIEW
- Parallel Courses IIIGoogle · ONSITE INTERVIEWGoogle interview questions
- Minimum Time to Complete Target CoursesMeta · ONSITE INTERVIEWMeta interview questions
- Critical Path Through Dependent TasksModular · PHONE SCREEN · ONSITE INTERVIEW
- Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
- Choose a Road to Maximize Average Route Toll IncreaseHarness · PHONE SCREEN
- Parallel Courses with DurationsCitadel · PHONE SCREENCitadel 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