How would you write a sort routine to ensure that identical elements in the input are maximally spread in the output?
Sigiloso
To Jeff's question, I believe the answer is a. The best answer I can think of is to: 1) Sort the array - nlogn 2) Find the number of occurances the most used number is (x) - n 3) Create x stacks - n 4) Loop through the sorted array, adding each number to a different stack (i % x) - n 5) Empty each stack one at a time onto the array - n I think there's a card trick that does something similar ;) Time complexity: O(nlogn) Space complexity: O(n)