0

How to achieve the following?

Input List: A,A,B,B,B,C,D,E,E,F

Expected Output List: C,D,F

Rick
  • 43
  • 6

1 Answers1

3

You could use group by and take only groups with exactly one element:

var input = new string[] {"A","A","B","B","B","C","D","E","E","F"};
var result = input.GroupBy(x => x).Where(x => x.Count() == 1).Select(x => x.Key).ToList();

Online-demo: https://dotnetfiddle.net/j2vraK

SomeBody
  • 7,515
  • 2
  • 17
  • 33