vector<string> Recommend(const vector <string> &remaining_commands) { if (remaining_commands.size() == 1) { return RecommendNames(remaining_commands[0]); } else { Trie* trie = GetTrie(remaining_commands[0]); if (trie == nullptr) { return {}; } else { return trie->GetPrefix(remaining_commands.back()); } } }
vector<string> Execute(const vector <string> &commands) { if (commands.size() < 2) { return Help(); } Trie* trie = GetTrie(commands[0]); if (trie == nullptr) { return {"Invalid trie name:", commands[0]}; } vector<string> result; for (int i = 1; i < int(commands.size()); i += 1) { if (i != 1) { result.push_back("~~~~~~~~~~~~"); } result.push_back(" > " + commands[i]); result = result + trie->GetPrefix(commands[i]); } return result; }