Before making name badges, find the longest name to see how wide they must be. Write longest_name(names) to return the longest name; if two are just as long, keep the earlier one. No names gives an empty string "".
longest_name({"Amy", "Benjamin", "Zoe"})→'Benjamin'longest_name({})→''string longest_name(const vector<string> &names)#include <string>
#include <vector>
using namespace std;
string longest_name(const vector<string> &names) {
string best = "";
for (const string &name : names) {
// your code here: if name is longer than best, make best name
}
return best;
}
Run tries the examples. When they look right, Submit.