You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good morning! Here's your coding interview problem for today.
This problem was asked by Twitter.
A teacher must divide a class of students into two teams to play dodgeball. Unfortunately, not all the kids get along, and several refuse to be put on the same team as that of their enemies.
Given an adjacency list of students and their enemies, write an algorithm that finds a satisfactory pair of teams, or returns False if none exists.
For example, given the following enemy graph you should return the teams {0, 1, 4, 5} and {2, 3}.
There are 2 valid solutions: team1: [0, 3] team2: [1, 4] OR team1: [0, 4] team2: [1, 3] when deterministically sorting by the first ID. team1[0] < team2[0]
Good morning! Here's your coding interview problem for today.
This problem was asked by Twitter.
A teacher must divide a class of students into two teams to play dodgeball. Unfortunately, not all the kids get along, and several refuse to be put on the same team as that of their enemies.
Given an adjacency list of students and their enemies, write an algorithm that finds a satisfactory pair of teams, or returns False if none exists.
For example, given the following enemy graph you should return the teams
{0, 1, 4, 5}
and{2, 3}
.On the other hand, given the input below, you should return False.
The text was updated successfully, but these errors were encountered: