We use cookies to provide you with an optimal experience and relevant communication.Cookie Policy
Back to course home
0% completed
Vote For New Content
Solution: Possible Bipartition
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] = [ai, bi] indicates that the person labeled ai does not like the person labeled bi, 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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible