Deer Park

Deer Park

  • NA
  • 39
  • 0

Excluding value on one list from other list-Taking too long

Dec 2 2012 2:32 PM
So, I have two list of int array. 
Say result1 and result2. I am using the code as follow which will exclude all the items that are in result2 from result1. 
But it's talking too much time, since I have thousands of item on both list of int array. Is there any other approach with which I can achieve same efficiently? Appreciated!!



List<int[]> result1 = new List<int[]> { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 } };
List<int[]> result2 = new List<int[]> { new int[] { 1, 2, 3 }, new int[] { 7, 8, 9 } };

result2.ForEach(t => result1.RemoveAll(z => z.OrderBy(k=>k).SequenceEqual(t.OrderBy(k=>k))));



Answers (8)