Search⌘ K
AI Features

Solution: Possible Bipartition

C# solution for the Possible Bipartition problem using the Graphs pattern.

Statement

You are given an integer n representing people labeled from 11 to n, and a list dislikes where each element is a pair [a_i, b_i] indicating that person a_i and person b_i dislike each other.

Determine whether it is possible to split all n people into exactly 22 groups such that no pair in dislikes has both people placed in the same group. Return true if such a partition exists, otherwise return false.

Constraints:

  • 11 \leq n 2000\leq 2000

  • ...