In the previous challenge, it was easy to print all the integers in order, since you did not have to access the original list. Once you had obtained the frequencies of all the integers, you could simply print each integer in order the correct number of times. However, if there is other data associated with an element, you will have to access the original element itself.
In the final counting sort challenge, you are required to print the data associated with each integer. This means, you will go through the original array to get the data, and then use some "helper arrays" to determine where to place everything in a sorted array.
If you know the frequencies of each element, you know how many times to place it, but which index will you start placing it from? It will be helpful to create a helper array for the "starting values" of each element.
You will be given a list that contains both integers and strings. In this challenge you just care about the integers. For every value from to , can you output , the number of elements that are less than or equal to ?
- , the size of the list .
- lines follow, each containing an integer and a string .
Output for all numbers from to (inclusive).
length of string