The whole family adds to the shopping list, and some things end up on it twice. Write tidy_list(items): the starter has already sorted it with sort; put each thing into tidy just once. Different capitals count as different things.
tidy_list({"milk", "eggs", "milk", "bread"})→['bread', 'eggs', 'milk']tidy_list({})→[]vector<string> tidy_list(vector<string> items)#include <algorithm>
#include <string>
#include <vector>
using namespace std;
vector<string> tidy_list(vector<string> items) {
sort(items.begin(), items.end());
vector<string> tidy;
for (const string &item : items) {
// your code here: add it only if it differs from the last in tidy
}
return tidy;
}
Run tries the examples. When they look right, Submit.