To remove all instances of a particular value from a C++ STL vector, you should use the _______ algorithm. 

  • find 
  • sort 
  • erase 
  • remove
While erase can remove elements from a vector, to efficiently remove all instances of a value, you'd first use remove to move those elements to the end and then use erase. This is known as the "erase-remove" idiom in C++.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *