Editorial for COCI '09 Contest 3 #3 Sort
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
By simply counting the number of times each number appears and sorting by those values we arrive at the solution. There are numerous ways we can implement that solution. To start, we can simply sort the numbers in time complexity and for each comparison scan the entire sequence in complexity.
A better solution is to precalculate all frequencies and use that data in sorting. Depending on implementation this can range from to .
Comments