using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.IO; using System.Xml; using System.Text.RegularExpressions; public interface ICodeRush { int? FindLeastFrequentNumber(IList list); } public class Solution : ICodeRush { public int? FindLeastFrequentNumber(IList list) { if (list != null && list.Any()) { var dict = new System.Collections.Concurrent.ConcurrentDictionary(); Parallel.ForEach(list, i => dict.AddOrUpdate(i, 1, (key, oldValue) => oldValue + 1)); var min = dict.Values.Min(); return dict.First(pair => pair.Value == min).Key; } return null; } }