Kodewick
Start learning →
Starter←→0 / 60

On the menu?

#032StarterMaps2 min

The noodle bar keeps its menu in a map: dish name → price. Write on_menu(menu, dish) to return true if dish is on the menu and false if not. Different capitals mean a different dish.

Examples
on_menu({{"noodles", 12}, {"dumplings", 10}}, "noodles")→True
on_menu({{"noodles", 12}, {"dumplings", 10}}, "pizza")→False
The functionbool on_menu(const map<string, int> &menu, const string &dish)
main.cpp
#include <map>
#include <string>
using namespace std;

bool on_menu(const map<string, int> &menu, const string &dish) {
    // your code here: is the dish on the menu?
    return false;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.