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.Count <= 0) { return null; } var dict = new System.Collections.Concurrent.ConcurrentDictionary(); System.Threading.Tasks.Parallel.ForEach(list, i => { dict.AddOrUpdate(i, 1, (k,v) => v += 1); }); return dict.OrderBy(c => c.Value).FirstOrDefault().Key; } }