You are viewing a single comment's thread. Return to all comments →
public static List<int> countingSort(List<int> arr) { var countMap = arr.GroupBy(n => n) .OrderBy(g => g.Key) .ToDictionary(g => g.Key, g => g.Count()); List<int> zeros = Enumerable.Repeat(0, 100).ToList(); for (int i = 0; i < zeros.Count; i++) { if (countMap.ContainsKey(i)) { zeros[i] = countMap.GetValueOrDefault(i); } } return zeros; }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 1
You are viewing a single comment's thread. Return to all comments →