What is the most efficient pattern/algorithm to compare two lists and find the delta between those two lists?

后端 未结 3 1822
借酒劲吻你
借酒劲吻你 2021-02-13 12:46

We have two lists, let\'s say students and their scores. I want to compare these two lists and find the delta between the new list and the old list, then find the least intrusi

3条回答
  •  自闭症患者
    2021-02-13 13:37

    Can you use Linq:

    List list1 = GetYourList1();
    List list2 = GetYourList2();
    var diff = list1.Except(list2);
    

    Your example specific:

    var diff = newList.Except(existingList);
    

    Not sure if it is the most efficient but it's concise :)

提交回复
热议问题