| 123456789101112131415161718 | /*  Create a function that takes an array of items, removes all  *  duplicate items and returns a new array in the same sequential  *  order as the old array (minus duplicates). */#include <set> // to use std::set#include <utility> // to use std::pairstd::vector<std::string> removeDups(std::vector<std::string> arr) {	std::vector<std::string> newArr;	std::set<std::string> unique;	for(int i=0;arr.size()>i;i++){		// insert will succeed if string is unique		std::pair<std::set<std::string>::iterator,bool>			r = unique.insert(arr[i]);		// unless insertion fails, add the string to newArr		if (r.second) newArr.push_back(arr[i]);	}	return newArr;}
 |