I was reviewing Data Structure. In the text book, there is a paragraph saying
"The direct approach is to sort it first, then uniquify it just as a sorted vector. Both steps can be finished within O(nlogn)."
then
"However there is a side-effect: the relative order of the items cannot be preserved."
finally
"Actually we can eliminate this side-effect without increasing the time complexity. Please implement it yourself."
Cannot find any clue. I'm not using STL right now while reviewing the text book. All I can imagine is to try to alter something during mergesort.
Anyone who's having a brighter view?
Sample case
Input: 5, 3, 5, 8, 5, 8, 8, 8, 13
Output: 5, 3, 8, 13