Order Service Deployments From a Dependency Manifest
Last updated: November 29, 2026
Quick Overview
Given service names and pairs (a, b) meaning service a must be deployed before service b, return a valid deployment order that is lexicographically smallest, or an empty list if the dependencies contain a cycle.
Flipkart
November 29, 20260
0
0 solved
Given service names and pairs (a, b) meaning service a must be deployed before service b, return a valid deployment order that is lexicographically smallest, or an empty list if the dependencies contain a cycle.
Flipkart runs hundreds of microservices that must be rolled out in dependency order before large sale events. This screen question checks Kahn's algorithm, cycle detection, and whether you can tweak the queue to get a deterministic order.
What the Interviewer Expects
- Model services as a directed graph and compute in-degrees
- Use Kahn's algorithm with a min heap for lexicographic order
- Detect a cycle when fewer than all nodes are emitted
- Include services that have no dependencies at all
- State O((V + E) log V) time
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 report the actual cycle to the release engineer?
- How would you group services into parallel deployment waves?
- What if a dependency list is updated while a rollout is in progress?
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: list of service names, list of
(before, after)pairs. - Output: an order respecting all pairs; among valid orders pick the lexicographically smallest so release runs are reproducible.
- Ret...
High-Level Design
Build adjacency lists and in-degree counts. Kahn's algorithm repeatedly emits a service with in-degree 0 and decrements its children. Using a min heap instead of a FIFO queue means that whenever s...