It wasn't as easy as doing a set difference as the a needed to keep the duplicate values.
a
Below is the answer in C#.
Where is the same as filter in JavaScript.
Where
filter
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(); } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 asfilter
in JavaScript.