8
Answers

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

Deer Park

Deer Park

12y
3.8k
1
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)