C# Improved algorithm
- by generixs
I have been asked at interview (C# 3.0) to provide a logic to remove a list of items from a list.
I responded
int[] items={1,2,3,4};
List<int> newList = new List<int>() { 1, 2, 3, 4, 5, 56, 788, 9 };
newList.RemoveAll((int i) => { return items.Contains(i); });
1) The interviewer replied that the algorithm i had employed will gradually take time if the items grow and asked me to give even better and faster one.What would be the efficient algorithm ?
2) How can i achieve the same using LINQ?
3) He asked me to provide an example for Two-Way-Closure? (General I am aware of closure,
what is Two-Way-Closure?, I replied there is no such term exists,but he did not
satisfy).