You are viewing a single comment's thread. Return to all comments →
Java:
public static List<Integer> countingSort(List<Integer> arr) { int[] freqArray = new int[100]; List<Integer> sortedList = new ArrayList<>(); for (int num : arr) { freqArray[num]++; } for (int i = 0; i < freqArray.length; i++) { for (int j = 0; j < freqArray[i]; j++) { sortedList.add(i); } } return sortedList; }
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 →
Java: