I'm trying to write a function that takes an array of unsorted positive integers N elements long.
The function should return the same array (no new allocations) with all duplicated integers replaced with -1 and moved to the end of the array.
So for example, the string:
Does anyone have a code snippet that accomplishes this? Sounds like a hash table could be the best approach here, but not sure.
Thanks much in advance!