title: Separate groups of people based on members
body: <p>I have groups of people. I need to move groups with at least one same member as far as possible from each other.</p>
  
  <p>Example:</p>
  
  <pre><code>GroupA - John, Bob, Nick
  GroupB - Jack, Nick
  GroupC - Brian, Alex, Steve
  </code></pre>
  
  <p>As you can see GroupA and GroupB overlap(they both contain Nick)
  I need an algorithm to set groups as GroupA->GroupC->GroupB</p>
  
  <p>Thank you</p>