List Every Valid Order to Run Onboarding Steps

Last updated: November 29, 2026

Quick Overview

A new user onboarding flow has n steps and constraints [a, b] meaning step a must come before step b. Return all orderings of the steps that satisfy every constraint, so product can review each possible flow.

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

0

0

0 solved


A new user onboarding flow has n steps and constraints [a, b] meaning step a must come before step b. Return all orderings of the steps that satisfy every constraint, so product can review each possible flow.

A Meta technical screen variant that pairs topological sort with backtracking, framed around enumerating the possible orders for a Facebook or Instagram new-user onboarding flow. The interviewer checks that you backtrack over Kahn's available set, undo in-degree changes correctly, and understand that the output can be exponential.

What the Interviewer Expects
  • Backtrack by choosing any currently available step
  • Restore in-degrees and the used flag when undoing a choice
  • Recognize the output size can be up to n factorial
  • Return an empty list when constraints contain a cycle
  • Keep the code free of shared-state bugs
Key Topics to Cover
backtracking
topological sort
enumeration
in-degree
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 count the orders without listing them?
  • How would you return only the k orders that minimize some cost?
  • Can you sample a uniformly random valid order?
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: n steps 0..n-1 and constraints [a, b].
  • Output: every permutation consistent with all constraints, in any order.
  • n is small (up to about 10), since the answer itself can be huge....
High-Level Design

Every valid order is produced by some sequence of choices in Kahn's algorithm: at each position, pick any step that is unused and has in-degree zero. Backtracking explores all of those choice sequence...


Submit Your Answer
Markdown supported