I'm trying to implement the Counting Sort algorithm with an ArrayList but I have some difficulties.
I in this piece of code I want to calculate the occurrence of each element in the ArrayList named l.
My code:
List<Integer> l = // initializing the given list
/** initialize the occurrence of each element in the count array **/
List<Integer> count = new ArrayList<>(max-min+1);
for(int i = 0; i < l.size(); i++){
//count[arr[i]-min]++;
int index = l.get(i) - min; //ok
int value = 0;
value = value++;
count.set(index, value);
}
I can't find out how to perform the increment.