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
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
topological sort
hierarchical graphs
grouping
cycle detection
Kahn's algorithm
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
  • 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 Problems
Sample 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...

Submit Your Answer
Markdown supported