fork(5) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var a = new List<string>{"A","A", "B", "C"};
  10. var b = new List<string>{"A", "B"};
  11. var res = a.Select(e => new {Key=e, Val=1})
  12. .Concat(b.Select(e => new {Key=e, Val=-1}))
  13. .GroupBy(e => e.Key, e => e.Val)
  14. .SelectMany(g => Enumerable.Repeat(g.Key, Math.Max(0, g.Sum())))
  15. .ToList();
  16. foreach (var e in res) {
  17. Console.WriteLine(e);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.04s 34088KB
stdin
Standard input is empty
stdout
A
C