Ad
  • Custom User Avatar

    While this is a clean solution, it is not a good practice, as it does perform badly: O(n*m), where n and m are the sizes of the arrays. Basically you are going though the second array as many times as items you have in the first array. You can accomplish this going through only once each array. See other solutions :) or mine if you wish.