Before the camping trip you check the list: packed says whether each thing is in the bag (true means packed). Write still_to_pack(packed): put the things not packed yet into todo, in alphabetical order. If everything is packed, return it empty.
still_to_pack({{"tent", true}, {"torch", false}, {"map", false}})→['map', 'torch']still_to_pack({})→[]vector<string> still_to_pack(const map<string, bool> &packed)#include <map>
#include <string>
#include <vector>
using namespace std;
vector<string> still_to_pack(const map<string, bool> &packed) {
vector<string> todo;
for (const auto &p : packed) {
// your code here: not packed yet goes into todo
}
return todo;
}
Run tries the examples. When they look right, Submit.