Counting Sort 1

  • + 0 comments
        public static List<Integer> countingSort(List<Integer> arr) {
            int[] res = new int[100];
            
            for (int val : arr) {
                res[val]++;
            }
            
            return Arrays.stream(res)
                        .boxed() // Convert int to Integer
                        .collect(Collectors.toList());
        }