title: Most efficient way to find repeated elements in different vectors
body: <p>I have a vector of strings that contains 5 elements called bottledNotes. I'm trying to find in a vector class called products, which inside has a vector of strings called productNames, what elements of bottledNotes are in productNames of each product. </p>
  
  <p>Ideally I would like to sort my results out in terms of repetition. Meaning, if the bottledNotes are repeated 5 times then return me that product. This is my first approach:</p>
  
  <pre><code>vector &lt;Products&gt; ofApp::returnProductsSuggestions(vector&lt;Products&gt; &amp;_notesProducts, vector&lt;string&gt; &amp;_bottledNotes){
  
  vector&lt;Products&gt; newProducts;
  
  for( int i = 0; i &lt; _notesProducts.size(); i++){
  //        cout &lt;&lt; "We made it into to the products" &lt;&lt; endl;
   for( int j = 0; j &lt; _notesProducts[i].productNotes.size(); j++){
  //        cout &lt;&lt; "We made it into to the productNotes" &lt;&lt; endl;
      for ( int k = 0; k &lt; _bottledNotes.size(); k++){
  
          if( five of the bottleNotes are repeated in the productNotes){
  
             newProducts.push_back(_notesProducts[i]);
          }
  
          if( four of the bottleNotes are repeated in the productNotes){
  
             newProducts.push_back(_notesProducts[i]);
          }
  
             //etc...
  
          if ( _notesProducts[i].productNotes[j] == _bottledNotes[k] &amp;&amp; i == 0){// we chec in the first set of products
  //               cout &lt;&lt; "These are the notes that are included in the first product: " &lt;&lt; _bottledNotes[k] &lt;&lt; endl;                    
               break;                                 }               
          }            
      }        
  }
  
   return _notesProducts;
  }
  </code></pre>
  
  <p>Is there any way to do this with this method? I'm open to suggestions.</p>