Medium
,DFS
,BFS
,Graph
We want to split a group of n
people (labeled from 1
to n
) 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]
= [, ] indicates that the person labeled does not like the person labeled , return true
if it is possible to split everyone into two groups in this way.
Example 1:
Example 2:
Example 3:
Constraints:
n
<= 2000dislikes.length
<= 104dislikes[i].length
== 2dislikes[i][j]
<= n
dislikes
are unique.KobeDec 21, 2022
Yen-Chi ChenWed, Dec 21, 2022
MarsgoatDec 21, 2022