You are viewing a single comment's thread. Return to all comments →
My Java solution with o(n) time complexity and o(n) space complexity:
public static List<Integer> countingSort(List<Integer> arr) { int[] freqArr = new int[100]; arr.forEach(num -> freqArr[num]++); return IntStream.range(0, 100) .boxed() .flatMap(i -> Collections.nCopies(freqArr[i], i).stream()) .collect(Collectors.toList()); }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 2
You are viewing a single comment's thread. Return to all comments →
My Java solution with o(n) time complexity and o(n) space complexity: