Reputation: 10974
How to calculate subtraction (set operation) of ordered lists in C#?
I am interesed in concise solution.
E.g. after execution of code:
List<int> a = new int[] { 1, 2, 5, 6, 7}.ToList();
List<int> b = new int[] { 1, 2, 3, 6}.ToList();
List<int> c = ListSubtract(a, b);
c
should contains 5, 7
.
It would be good to perform in O(a.Count()+b.Count())
operations, but it is not critical.
Thanks.
Upvotes: 3
Views: 1079