Split Sellers Into Two Audit Teams With No Conflicted Pairs

Last updated: November 29, 2026

Quick Overview

Some pairs of marketplace sellers have a conflict of interest and must be audited by different teams. Given n sellers and the conflict pairs, return True if sellers can be split into two teams so that every conflicted pair is on opposite teams.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Some pairs of marketplace sellers have a conflict of interest and must be audited by different teams. Given n sellers and the conflict pairs, return True if sellers can be split into two teams so that every conflicted pair is on opposite teams.

An Amazon onsite graph question set in marketplace trust and safety. The interviewer is checking whether you recognize bipartite checking, color with BFS across every component, and can explain that an odd cycle is the exact obstruction.

What the Interviewer Expects
  • Recognize the problem as bipartite graph testing
  • Two-color each component with BFS
  • Detect a conflict when neighbors share a color
  • Loop over all nodes to cover disconnected components
  • Explain the odd-cycle characterization
Key Topics to Cover
Bipartite Graphs
BFS
Graph Coloring
Connected Components
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
  • Return the actual team assignment, or an odd cycle as proof of failure.
  • What if there are three teams instead of two?
  • How would you handle conflict pairs arriving one at a time?
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: integer n (sellers labeled 0..n-1) and list conflicts of pairs [a, b]. Output: True if a 2-coloring exists with every pair split....

High-Level Design

Build an adjacency list. For each uncolored seller, start a BFS and give it color 0. Each neighbor gets the opposite color; if a neighbor already has the same color as the current node, two conflicted...


Submit Your Answer
Markdown supported