Plan Deployment Waves for Dependent Rakuten Microservices

Last updated: November 29, 2026

Quick Overview

Given a set of services and dependency pairs (a, b) meaning a must be deployed before b, return the deployments grouped into waves where each wave contains every service whose dependencies are all in earlier waves, or report a cycle.

Rakuten
Coding & Algorithms
Software Engineer
Rakuten
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a set of services and dependency pairs (a, b) meaning a must be deployed before b, return the deployments grouped into waves where each wave contains every service whose dependencies are all in earlier waves, or report a cycle.

Rakuten runs a large internal platform where many teams own microservices with ordering constraints during releases. Onsite interviewers like this topological sort variant because it adds levels, deterministic ordering and cycle reporting on top of the textbook version.

What the Interviewer Expects
  • Build adjacency list and in-degree map
  • Use Kahn's algorithm level by level
  • Detect cycles by counting processed nodes
  • Sort each wave for deterministic output
  • Explain O(V + E)
Key Topics to Cover
topological sort
Kahn's algorithm
cycle detection
BFS levels
dependency graphs
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
  • Each wave can deploy at most 5 services in parallel. How does that change the plan?
  • Return the services that are actually on the cycle, not just those blocked by it.
  • A service deploy fails halfway. Which later services must be held back?
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: list of service names and a list of edges a -> b. Output: list of waves, each sorted. Every edge must point from an earlier wave to a later one, and each service should be placed in the earli...

High-Level Design

Kahn's algorithm processed in layers: services with in-degree zero form wave one. Removing them decrements their dependents; anything that drops to zero forms the next wave. Placing a node as soon as ...


Submit Your Answer
Markdown supported

Related Questions