Order Listing Onboarding Steps From Dependency Rules
Last updated: November 29, 2026
Quick Overview
Listing creation has steps such as address, photos, pricing, identity verification, and publish, with rules saying one step must be completed before another. Return a valid order that is lexicographically smallest among valid orders, or report the steps involved in a cycle.
Airbnb
November 29, 20260
0
0 solved
Listing creation has steps such as address, photos, pricing, identity verification, and publish, with rules saying one step must be completed before another. Return a valid order that is lexicographically smallest among valid orders, or report the steps involved in a cycle.
Airbnb's host onboarding flow is assembled from steps owned by different teams, and a bad rule can silently create a circular requirement that traps hosts. The interviewer checks that you know Kahn's algorithm, can make the output deterministic, and surface a useful error instead of just returning False.
What the Interviewer Expects
- Model steps as nodes and rules as directed edges
- Use Kahn's algorithm with a min-heap for the deterministic order
- Detect cycles when not every node is emitted
- Report the stuck nodes to help debugging
- Validate rules that mention unknown steps
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you report one concrete cycle path instead of every stuck node?
- Some steps are optional per market. How does that change the graph?
- How would you find steps that can run in parallel in the UI?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: a list of step names and (before, after) rules. Output: an ordering that respects every rule, choosing the alphabetically smallest available step whenever there is a choice. If no ordering exi...
High-Level Design
Build adjacency lists and indegree counts. All indegree-zero steps are ready. Repeatedly take the smallest ready step (min-heap), append it, and decrement its children's indegrees, pushing any that hi...