Intersect,Except 自己看着用

解决方案 »

  1.   

    你是怎么做的呢?时间复杂度是多少?这个问题,用字典来解决效率最高,然后遍历两个数组一次。时间复杂度a.Length+b.Length
      

  2.   

    转化为list<t>,然后利用Distinct()函数
                List<string> a = new List<string>();
                string[] b = new string[] { "1", "1" };
                List<string> c = b.ToList<string>().Distinct(); 
                c.ToArry();
    输出c 里只有 “1”;
    如果是简单的类型,如string,int,如果是复杂的类,需要指定comparer其实也很麻烦