Possible Bipartition
Split n people into two dislike-free groups using 2-colouring graph BFS or DFS.
01The problem
We want to split a group of n people (labeled 1 to n) into two groups of any size. Each person may dislike some other people.
Given an integer n and an array dislikes where dislikes[i] = [a, b] denotes that person a and person b dislike each other and cannot belong to the same group, return true if it is possible to split everyone into two groups, or false otherwise.
Loading the rest of the lesson…