Before closing, the bakery checks what is nearly sold out so it can bake more tomorrow. Write low_stock(stock) to return a vector of the names with fewer than 3 left, in alphabetical order (the order the map already has).
low_stock({{"bun", 5}, {"pie", 2}, {"cake", 0}})→['cake', 'pie']low_stock({{"tart", 4}})→[]vector<string> low_stock(const map<string, int> &stock)#include <map>
#include <string>
#include <vector>
using namespace std;
vector<string> low_stock(const map<string, int> &stock) {
vector<string> names;
for (const auto &item : stock) {
// your code here: if fewer than 3 are left, put the name in names
}
return names;
}
Run tries the examples. When they look right, Submit.