Counting Sort 1

  • + 0 comments

    Java 8

    public static List<Integer> countingSort(List<Integer> arr) {
    // Write your code here
    
        // Integer maxInt = Collections.max(arr);
    
        int[] intArr = new int[100];
    
        for (Integer arg : arr) {
            intArr[arg] = intArr[arg] += 1;
        }
    
        return Arrays.stream(intArr).boxed().collect(Collectors.toList());
    }