Counting Sort 1

  • + 0 comments
    ** The Collections.nCopies(100, 0) creates a list with 100 elements, all initialized to 0 **
    

    List count = new ArrayList<>(Collections.nCopies(100, 0)); for (int num : arr) { count.set(num, count.get(num) + 1); } return count; }