Quicksort is O (n log n) as the standard “good algo” method for sorting a list. So there must be some kind of “trick” to go to O (n) time.
The only real trick for this data is from 0 to n ^ 2-1 ... but I can’t imagine how it can be used to sort in O (n) time ....
PS Sounds like homework, not that you are a "puzzle for knowledge"
PPS I can't help but think of sorting the bucket.
source
share