Prepare for Full Counting Sort


Collapse Content

In the previous challenge, it was easy to print all the integers in order, since you did not need to access the original list. Once you had the frequencies of each integer, you could just print each integer in order the correct number of times. However, if there is other data associated with an element, you will need to access the original element itself.

In the final counting sort challenge, you will need 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.

You will be given a list that contains both integers and strings. In this challenge you just care about the integers. For every value i from 0 to 99, can you output L, the number of elements that are less than or equal to i?

Input Format

  • t - the number of test cases. t cases follow:
  • n - the size of the list ar. n lines follow, each containing an integer x, and a string, s.

Output Format
Output L for all numbers from 0 to 99 (inclusive).

Getting the Input
Optional Java boilerplate is provided below which scans the input into Blobs where each Blob contains a integer num and a String string. In this challenge, you just care about the num of each Blob.

Click for More

Challenge

For every value i from 0 to 99, can you output L, the number of elements that are less than or equal to i?

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

  • Received this runtime error.
    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Scanner.java:909)
    at java.util.Scanner.next(Scanner.java:1530)

    cont...
  • @Rod, sorry, new code to scan the input has been added. You can click "Reset Code" to load it.

Contact Us
Sign in or email us at [email protected]