logo CodeStepByStep logo

removeDuplicates

Language/Type: C++ Set Vector collections
Related Links:
Author: Marty Stepp (on 2016/07/03)

Write a function named removeDuplicates that accepts as a parameter a reference to a Vector of integers, and modifies it by removing any duplicates. Note that the elements of the vector are not in any particular order, so the duplicates might not occur consecutively. You should retain the original relative order of the elements. Use a Set as auxiliary storage to help you solve this problem. For example, if a vector named v stores {4, 0, 2, 9, 4, 7, 2, 0, 0, 9, 6, 6}, the call of removeDuplicates(v); should modify it to store {4, 0, 2, 9, 7, 6}.

Type your solution here:


This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.