Order Ride Maintenance Tasks Respecting Prerequisite Checks
Last updated: November 29, 2026
Quick Overview
Given ride maintenance task ids and prerequisite pairs (before, after), return an order that satisfies every prerequisite, choosing the alphabetically smallest ready task at each step, or report the tasks stuck in a cycle.
Disney
November 29, 20260
0
0 solved
Given ride maintenance task ids and prerequisite pairs (before, after), return an order that satisfies every prerequisite, choosing the alphabetically smallest ready task at each step, or report the tasks stuck in a cycle.
An onsite coding round in the style of Disney Parks and Walt Disney Imagineering software teams, where overnight ride maintenance must finish in a safe order before morning test runs. The interviewer checks topological sorting, cycle detection, and a deterministic tie-break.
What the Interviewer Expects
- Model tasks as a directed graph with in-degrees
- Use Kahn's algorithm with a min-heap for deterministic order
- Detect cycles by comparing processed count to task count
- Report which tasks are blocked, not just that a cycle exists
- Validate unknown task ids
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Each task has a duration and crews work in parallel; what is the earliest finish time?
- How would you show the actual cycle path to the maintenance lead?
- Tasks get added while the plan runs; how do you update incrementally?
- How would you prefer safety-critical tasks when several are ready?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: a list of task ids and a list of (before, after) edges. Output: a full ordering where every before precedes its after. When several tasks are ready, pick the smallest id so two runs prod...
High-Level Design
Compute in-degrees and adjacency lists. Push every task with in-degree 0 onto a min-heap. Repeatedly pop the smallest, append it, and decrement the in-degree of its children, pushing any that reach 0....