Order Experiment Rollouts Respecting Prerequisite Experiments

Last updated: November 29, 2026

Quick Overview

TikTok runs many feature experiments, and some can only launch after others finish. Given experiment IDs and prerequisite pairs (a, b) meaning a must launch before b, return a valid launch order, or report the experiments involved in a cycle.

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

0

0

0 solved


TikTok runs many feature experiments, and some can only launch after others finish. Given experiment IDs and prerequisite pairs (a, b) meaning a must launch before b, return a valid launch order, or report the experiments involved in a cycle.

Experimentation platforms at TikTok coordinate thousands of concurrent tests with dependencies between them, so topological sort questions are framed this way in technical screens. The interviewer checks Kahn's algorithm, cycle detection, and whether you return useful diagnostics instead of just failing.

What the Interviewer Expects
  • Builds adjacency and in-degree maps including isolated experiments
  • Uses Kahn's algorithm with a queue of zero in-degree nodes
  • Detects a cycle when fewer nodes are output than exist
  • Returns the nodes left with positive in-degree as the cycle diagnostic
  • Discusses deterministic ordering for reproducible launch plans
Key Topics to Cover
topological sort
Kahn's algorithm
cycle detection
DAG
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 return the order in waves so independent experiments can launch in parallel?
  • How would you find one concrete cycle path to show the user?
  • How do you handle new dependencies added 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 Problems
Sample Answer
Requirements
  • Input: experiments: list[str], prereqs: list[tuple[str, str]].
  • Output: (order, None) if valid, or (None, stuck) where stuck is a sorted list of experiments that cannot launch because of ...
High-Level Design

Kahn's algorithm: compute in-degrees, start with all zero in-degree nodes, repeatedly pop one, append it to the order, and decrement its children. Any child that reaches zero becomes ready.

If the ou...


Submit Your Answer
Markdown supported