Back to course home
0% completed
Vote For New Content
Possible Bipartition (medium)
Problem Statement
There are n
people (labeled from 1 to n), and need to split them into two groups of any size. Each person may dislike some other people, and they should not go into the same group.
Given the integer n
and the array dislikes where dislikes[i] = [a<sub>i</sub>, b<sub>i</sub>] indicates that the person labeled a<sub>I</sub> does not like the person labeled b<sub>I</sub>, return true
if you can divide each person into two groups in this way. Otherwise, return false
.
Examples
Example 1
- Input: n = 5, dislikes = [[1, 2], [2, 3], [3, 4], [4, 5]]
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page