Kodewick
Start learning →
Basic←→0 / 60

Lost and found

#050BasicAlgorithmsStrings3 min

The school has a lost-and-found box, and box lists what's in it. Write in_the_box(box, thing): use find to look for thing, and return true if it's there, false if not. Names must match exactly, capitals included.

Examples
in_the_box({"umbrella", "scarf", "glove"}, "scarf")→True
in_the_box({"umbrella", "scarf"}, "hat")→False
The functionbool in_the_box(const vector<string> &box, const string &thing)
main.cpp
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

bool in_the_box(const vector<string> &box, const string &thing) {
    // your code here: look for thing with find
    return false;
}
Ctrl + Enter runs too
Result

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