You can do this in one line with C#. Not saying this is the most efficient method, but it's neat. Assuming Haircut's numbers array:
You would obviously want to make that safer but it will return 6 correctly
Code:
int[] numbers = { 2, 6, 8, 4, 5, 6, 9, 10, 1 };
numbers.GroupBy(n => n)
.Where(g => g.Count() > 1)
.Select(g => g.Key)
.FirstOrDefault();
You would obviously want to make that safer but it will return 6 correctly