title: Compare two arrays and create new array with equal elements in C
body: <p>The problem is to check two arrays for the same integer value and put matching values in a new array.</p>
  
  <p>Let say I have two arrays  </p>
  
  <p><code>a[n] = {2,5,2,7,8,4,2}</code><br>
  <code>b[m] = {1,2,6,2,7,9,4,2,5,7,3}</code>  </p>
  
  <p>Each array can be a different size.</p>
  
  <p>I need to check if the arrays have matching elements and put them in a new array. The result in this case should be:</p>
  
  <p><code>array[] = {2,2,2,5,7,4}</code></p>
  
  <p>And I need to do it in <strong>O(n.log(n) + m.log(m))</strong>.</p>
  
  <p>I know there is a way to do with merge sorting or put one of the array in a hash array but I really don't know how to implement it.</p>
  
  <p>I will really appreciate your help, thanks!!!</p>