fork(2) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var testData = new List<List<int>>
  10. {
  11. new List<int> { 1, 2, 3 },
  12. new List<int> { 2, 1, 3 },
  13. new List<int> { 6, 8, 3, 45,48 },
  14. new List<int> { 9, 2, 4 },
  15. new List<int> { 9, 2, 4, 15 }
  16. };
  17.  
  18. var testSets = testData.Select(s => new HashSet<int>(s));
  19.  
  20. var groupedSets = testSets.GroupBy(s => s, HashSet<int>.CreateSetComparer());
  21.  
  22. foreach(var g in groupedSets)
  23. {
  24. var setString = String.Join(", ", g.Key);
  25. Console.WriteLine($" {g.Count()} | {setString}");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.01s 30064KB
stdin
Standard input is empty
stdout
 2 | 1, 2, 3
 1 | 6, 8, 3, 45, 48
 1 | 9, 2, 4
 1 | 9, 2, 4, 15