Order Seller Onboarding Tasks So Each Team Works Contiguously
Last updated: November 29, 2026
Quick Overview
Seller onboarding has n tasks, each owned by a team or unowned, with dependency pairs between tasks. Return an order that respects all dependencies and keeps each team's tasks contiguous, or an empty list if impossible.
Amazon
November 29, 20260
0
0 solved
Seller onboarding has n tasks, each owned by a team or unowned, with dependency pairs between tasks. Return an order that respects all dependencies and keeps each team's tasks contiguous, or an empty list if impossible.
This is a two-level topological sort, a harder Amazon onsite pattern framed around Seller Central onboarding where compliance, payments, and catalog teams each own tasks. The interviewer checks that you see the need to sort teams and tasks separately and recombine them.
What the Interviewer Expects
- Give each unowned task its own singleton team
- Derive team-level edges from cross-team task edges
- Topologically sort tasks and teams independently
- Bucket tasks by team in task order, then emit buckets in team order
- Return empty if either sort finds a cycle
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
- Why is a single topological sort over tasks not enough?
- Can a valid task order exist while the team order has a cycle?
- How would you minimize the number of handoffs if contiguity were a soft constraint?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: n, team[i] (a team id or -1), and (a, b) pairs meaning task a precedes task b. Output: one order of all tasks where dependencies hold and tasks of the same team appear consecutively; []...
High-Level Design
Contiguity means teams themselves must be ordered: if a task of team X precedes a task of team Y, all of X comes before all of Y. So there are two graphs:
- Task graph with every edge.
- **Team g...