title: Fastest Search algorithm in 2D array
body: <p>So, I have a 2D array, <code>int a[X][Y];</code>
  <code>X</code> can go up to <em>10 000 000</em> and <code>Y</code> is maximum <em>6</em>.
  Given an array <code>int v[Z]</code> (<em>Z &lt;= Y</em>), I have to see if I find a line in a that contains all the elements from <code>v</code>.</p>
  
  <p>What would be the fastest algorithm for this matter and how would you implement this?</p>
  
  <p>I have already tried the classic method of taking line by line and then with the 2 fors search, one for v elements and one for a elements but it takes too long.</p>
  
  <p>What would be the best (fastest) approach ?</p>
  
  <pre><code>int check()
  {
      int nrfound;
  
      for (int l = 0; l &lt; lines_counter; l++) for each line in a array
      {
          nrfound = 0;
  
          for (int i = 0; i &lt; n; i++) { // for each element in v array
  
              for (int j = 0; j &lt; m; j++) // for each element in a[l] line
                  if (v[i] == a[l][j])
                      nrfound++;
              if (nrfound == Z)
                  return 0;
          }
      }
      return 1;
  }
  </code></pre>