Editorial for SAC '22 Code Challenge 3 P3 - Bob 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.

Author: maxcruickshanks

First, find log10(max(Ai))+1 by iterating across the array.

Second, create an array of pairs that store the value modulo the respective round (e.g., for round 1, mod the value by 101; for round 2, mod the value by 102; etc.).

Third, sort that array by the modulo value using a custom comparator or built-in functions.

Finally, output that round and repeat the second and third steps until you have reached the final round.

Time Complexity: O(Nlog(N)log10(max(Ai))+1)


Comments

There are no comments at the moment.