The tea shop writes down the name of every drink it sells. Write best_seller(sales) to return the drink that sold the most. If two sold just as many, return the one that comes first alphabetically. At least one drink was sold.
best_seller({"latte", "tea", "latte"})→'latte'best_seller({"mocha"})→'mocha'string best_seller(const vector<string> &sales)#include <map>
#include <string>
#include <vector>
using namespace std;
string best_seller(const vector<string> &sales) {
map<string, int> count;
for (const string &drink : sales) {
// your code here: add 1 to this drink's count
}
string best = "";
int most = 0;
for (const auto &item : count) {
// your code here: if it beats most, remember this drink and its count
}
return best;
}
Run tries the examples. When they look right, Submit.