Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Possible Bipartition

XPChallenge Points: 20
levelLevel: Medium

You are given n people, labeled from 1 to n.
Each person may dislike some other people, and two people who dislike each other cannot be placed in the same group.
Your goal is to determine whether it’s possible to split all people into two groups such that no two people who dislike each other are in the same group.
Return True if such a bipartition is possible, otherwise False.

Example 1:

Input: n = 4 dislikes = [[1,2],[1,3],[2,4]]

Output: True

Example 2:

Input: n = 3 dislikes = [[1,2],[1,3],[2,3]]

Output: False

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result