title: An efficient way to find matching items in N lists?
body: <p>Given a number of lists of items, find the lists with matching items.</p>
  
  <p>The brute force pseudo-code for this problem looks like:</p>
  
  <pre><code>foreach list L
      foreach item I in list L
          foreach list L2 such that L2 != L  
              for each item I2 in L2
                  if I == I2
                      return new 3-tuple(L, L2, I) //not important for the algorithm
  </code></pre>
  
  <p>I can think of a number of different ways of going about this - creating a list of lists and removing each candidate list after searching the others for example - but I'm wondering if there is a better algorithm for this?</p>
  
  <p>I'm using Java, if that makes a difference to your implementation. </p>
  
  <p>Thanks</p>