Order Microservice Deployments From Service Dependency Manifests

Last updated: November 29, 2026

Quick Overview

Each service in a release lists the services it depends on, which must be deployed first. Return a valid deployment order that is lexicographically smallest, or report the services trapped in a dependency cycle.

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

0

0

0 solved


Each service in a release lists the services it depends on, which must be deployed first. Return a valid deployment order that is lexicographically smallest, or report the services trapped in a dependency cycle.

Walmart Labs runs a large microservice estate behind Walmart.com checkout, cart and pricing, and release tooling has to sequence deploys. The interviewer checks a correct Kahn's algorithm, deterministic tie-breaking with a heap, and a useful error when the graph has a cycle.

What the Interviewer Expects
  • Model the problem as a directed graph from dependency to dependent
  • Use Kahn's algorithm with in-degree counts
  • Break ties deterministically with a min-heap
  • Detect cycles by comparing output length to the node count
  • Include services that appear only as dependencies
Key Topics to Cover
topological sort
Kahn's algorithm
heaps
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 group services into parallel deployment waves?
  • How would you print one actual cycle rather than every stuck service?
  • What if a dependency is optional and can be skipped to break a cycle?
  • How would you roll back if a service in the middle of the order fails?
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: dict service -> list of dependencies. A dependency may not appear as a key (for example a shared catalog service with no deps of its own), so it still must be deployed. Duplicate entries in...

High-Level Design

Edges go from dependency to dependent. Compute in-degrees (number of unmet dependencies). Services with in-degree zero are ready. Instead of a FIFO queue, use a min-heap of ready names: always deployi...


Submit Your Answer
Markdown supported