There are `n` people labeled `1` to `n`. `dislikes[i] = [a_i, b_i]` means person `a_i` and person `b_i` dislike each other and cannot be in the same group. Return `true` if everyone can be split into two groups (of any size) so that no group holds two people who dislike each other, and `false` otherwise.
There are n people labeled 1 to n. dislikes[i] = [a_i, b_i] means person a_i and person b_i dislike each other and cannot be in the same group. Return true if everyone can be split into two groups (of any size) so that no group holds two people who dislike each other, and false otherwise.
Example 1:
Input: {"n":4,"dislikes":[[1,2],[1,3],[2,4]]}
Output: true
Constraints:
1≤n≤2000
0≤dislikes.length≤104
dislikes[i].length==2
1≤ai<bi≤n
All the pairs of dislikes are unique
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":4,"dislikes":[[1,2],[1,3],[2,4]]}
Turn the 3 dislike pairs into an adjacency list. Every dislike must end up crossing between group A and group B.