Interview Question
Software Engineer in Tests1. Sort the teams in decreasing order of the number of members in them.
2. Pick the 1st team (with maximum members) and arrange them around the table.
3. Pick the 2nd team and arrange the members between the already present members around the table.
Repeat step 3 until no teams are left
1) Sit one member from each of the n teams in sequence. That is, if TM[i,j] is i-th member of team j, and Mi is number of members in i-th team, sit like this: TM[1,1], TM[1,2], TM[1,3], ... TM[1,M1], TM[2,1], TM[2,2],...TM[2,M2], and so on.
When the circular sitting is finished, check if team of last two members is same. That is, TM[n] == TM[1]. If so, swap TM[n-1,Mn-1] & TM[n,Mn].
?
as long as the max number of members in a team, <= # of rest people
- geniusxsy November 18, 2009there's always a simple greedy solution