Startup Order for Checkout Services With Dependency Checks
Last updated: November 29, 2026
Quick Overview
Given a list of service names and pairs (a, b) meaning service a needs b running first, return a startup order that respects every dependency, choosing the alphabetically smallest ready service at each step, or report the services stuck in a cycle.
eBay
November 29, 20260
0
0 solved
Given a list of service names and pairs (a, b) meaning service a needs b running first, return a startup order that respects every dependency, choosing the alphabetically smallest ready service at each step, or report the services stuck in a cycle.
eBay runs checkout, payments, cart and inventory as many services that must come up in a safe order during a region failover. The interviewer checks topological sort, deterministic tie breaking with a heap, and whether cycle errors are actionable for an on-call engineer.
What the Interviewer Expects
- Model dependencies as edges from prerequisite to dependent
- Use Kahn's algorithm with in-degree counts
- Use a min-heap for a deterministic order
- Detect cycles by comparing output length to the service count
- Validate unknown service names
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
- How would you start independent services in parallel waves and minimize total time?
- Return the exact cycle path rather than just the stuck set.
- What if a dependency is optional and can be started degraded?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: services (unique names) and deps as (a, b) meaning a depends on b. Output: an ordering where every b comes before its a. When several services are ready, pick the alphabetically smallest ...
High-Level Design
Edge b -> a for each dependency, in-degree of a increases. Services with in-degree 0 can start now. Kahn's algorithm repeatedly removes a ready service and decrements its dependents. A min-heap repl...