Possible Bipartition
A medium-tier problem at 52% community acceptance, tagged with Depth-First Search, Breadth-First Search, Union Find. Reported in interviews at Coupang and 5 others.
Possible Bipartition asks if you can split a graph's nodes into two groups so no edge connects nodes in the same group. It's a medium-difficulty graph coloring problem that appears in assessments at Coupang, Arcesium, Samsung, Waymo, Pinterest, and LinkedIn. The 51.5% acceptance rate tells you most candidates miss the trick on first attempt. The obvious intuition fails silently here: you can't just greedily assign colors. If this problem hits your live OA and you blank on the two-coloring pattern, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Possible Bipartition"
Possible Bipartition is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe core pattern is graph bipartiteness: you need to check if the graph is 2-colorable. Use BFS or DFS to assign alternating colors to adjacent nodes. If you ever try to color a node a color it's already been assigned a different color, the graph isn't bipartite. Most candidates waste time building adjacency lists wrong or confuse the problem with cycle detection. Union Find also works here, but it's slower than a straight color traversal. The trap is thinking this is about connected components or independence sets. It's neither. It's pure graph coloring with exactly two colors. When you're stuck on the structure during your assessment, StealthCoder reads the problem and surfaces a working coloring solution in seconds.
Pattern tags
You know the problem.
Make sure you actually pass it.
Possible Bipartition recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Possible Bipartition interview FAQ
Is this really a medium problem?+
The 51.5% acceptance rate reflects that the two-coloring insight isn't automatic for most candidates. Once you see it's a bipartiteness check, implementation is straightforward BFS or DFS. But the gap between 'not seeing it' and 'seeing it' is real. Study the pattern now so you don't hit that gap live.
Which approach should I use, BFS or DFS?+
Either works. BFS is marginally cleaner for this problem because you process neighbors level by level, making the color assignment more visible. DFS is equally valid. The companies asking this (Coupang, Samsung, Waymo, LinkedIn) don't care which you pick as long as you handle disconnected components and don't revisit nodes incorrectly.
When does the greedy approach fail?+
Greedy fails the moment an odd cycle exists. You color nodes 0, 1, 2 alternating, then edge 2-0 forces node 2 and node 0 to have the same color. No greedy assignment prevents this. You need full graph traversal to detect it. That's why BFS/DFS coloring, not assignment heuristics, is the real solution.
How does this relate to Union Find?+
Union Find can solve bipartition if you union each node with the opposite of its neighbors, then check for conflicts. It works but adds overhead. BFS coloring is simpler and faster. Save Union Find for problems that explicitly need connectivity or least common ancestor queries.
What if the graph has multiple components?+
You must loop through all unvisited nodes and run BFS or DFS on each. A disconnected graph is still bipartite if every component is bipartite. Missing this loop is a common bug. Check the problem constraints to see if you're guaranteed a connected graph, then handle both cases to be safe.
Want the actual problem statement? View "Possible Bipartition" on LeetCode →