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:
1136788999
becomes ...
136789-1-1-1-1
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!
~Steve