re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

It wasn't as easy as doing a set difference as the a needed to keep the duplicate values.

Below is the answer in C#.

Where is the same as filter in JavaScript.

using System.Linq;
using System.Collections.Generic;

public class Kata
{
  public static int[] ArrayDiff(int[] a, int[] b)
  {
    var hash = new HashSet<int>(b);
    return a.Where(_ => !hash.Contains(_)).ToArray();
  }
}
code of conduct - report abuse