You are viewing a single comment's thread. Return to all comments →
A couple Python solutions:
Fun one liner:
def countingSort(arr): return [arr.count(i) for i in range(100)]
Not very optimal, O(n^2) time complexity
Better but more verbose solution for O(n) time complexity:
def countingSort(arr): counts = [0 for i in range(100)] for n in arr: counts[n] += 1 return [counts[i] for i in range(100)]
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 →
A couple Python solutions:
Fun one liner:
Not very optimal, O(n^2) time complexity
Better but more verbose solution for O(n) time complexity: