Deterministic Microservice Rollout Order From a Dependency Manifest

Last updated: November 29, 2026

Quick Overview

Given service names and pairs (a, b) meaning a must be deployed before b, return a deployment order that respects all constraints and is lexicographically smallest, or an empty list if a cycle makes rollout impossible.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given service names and pairs (a, b) meaning a must be deployed before b, return a deployment order that respects all constraints and is lexicographically smallest, or an empty list if a cycle makes rollout impossible.

Uber runs thousands of microservices and safe rollouts depend on ordering. The screen checks Kahn's algorithm, cycle detection through the processed count, and the small twist of a min-heap to make the order deterministic, which matters for reproducible deploy plans.

What the Interviewer Expects
  • Build adjacency lists and in-degree counts
  • Use Kahn's algorithm with a min-heap for lexicographic order
  • Detect cycles when fewer than n services are emitted
  • Include services with no constraints
  • State O((V + E) log V)
Key Topics to Cover
topological sort
Kahn's algorithm
min-heap
cycle detection
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you produce deployment waves where each wave can roll out in parallel?
  • If there is a cycle, how would you report which services are involved?
  • How would you limit rollout to at most 3 services at a time?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: services list of names, deps list of (before, after).
  • Output: a topological order, choosing the alphabetically smallest available service at each step; [] if a cycle exists....
High-Level Design

Kahn's algorithm repeatedly emits a service with in-degree zero and decrements its dependents. Many services may be ready at once; picking the smallest with a min-heap yields the lexicographically sma...


Submit Your Answer
Markdown supported