Earliest Concurrent Workflow Stages
Updated
Problem statement
Each pair [before, after] in precursorSteps says the first workflow step must finish before the second may begin. The pairs can arrive in any order.
Return a list of stages, each itself a list of step names. All steps in a stage run concurrently. Every step must appear exactly once, in its earliest possible stage: a step with no prerequisites belongs to stage 0, and every other step belongs one stage after its latest prerequisite.
Include exactly the names mentioned in the pairs. Empty input returns an empty list of stages. For this exercise, assume repeated copies of the same dependency count once, and sort names within each stage in ascending ASCII order. Preserve the names exactly, including case and internal spaces.
Function
createWorkflowStages(precursorSteps: String[][]) → String[][]Examples
Example 1
precursorSteps = [["clean","build"],["metadata","binary"],["build","link"],["link","binary"],["clean","metadata"],["build","resources"]]return = [["clean"],["build","metadata"],["link","resources"],["binary"]]Clean starts in stage 0. Build and metadata follow in stage 1. Link and resources then start in stage 2. Binary waits for both metadata and link, so its earliest stage is 3.
Example 2
precursorSteps = [["boil","serve"],["chop","boil"],["stir","boil"],["set table","serve"]]return = [["chop","set table","stir"],["boil"],["serve"]]Chop, set table, and stir have no prerequisites. Boil follows chop and stir. Serve must wait for boil, so it starts in stage 2 even though set table finishes earlier.
Constraints
- For this exercise, assume
0 <= precursorSteps.length <= 500. - Every pair contains exactly two step names.
- Each name has 1 to 50 printable ASCII characters and contains at least one non-space character.
- The directed dependency graph is acyclic.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Package Install OrderVerily · ONSITE INTERVIEW
- Task Build Order and File-Change RerunsVanta · PHONE SCREEN
- Topological Sort with Secondary OrderingRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
- Available Recipes from Initial SuppliesAmazon · PHONE SCREEN
- Validate CSV References and Field DependenciesStripe · PHONE SCREENStripe interview questions
- Recipes You Can PrepareIndeed · PHONE SCREENIndeed interview questions
- Data Pipeline Steps with Search and Run OrderRippling · PHONE SCREENRippling interview questions
- Propagate Spreadsheet Cell UpdatesOpenAI · PHONE SCREENOpenAI interview questions
- Lexicographically Smallest Topological OrderCoinbase · PHONE SCREENCoinbase interview questions