Embercode
✕
The STLQuick quiz

Grouping

6 questions. Covers Grouping with maps of lists.

Questions 1 to 5 of 6

  1. 1. What does this print? ``cpp std::map<std::string, std::vector<int>> g; g["b"].push_back(1); g["a"].push_back(2); g["b"].push_back(3); std::cout << g.size() << ' ' << g.begin()->first << ' ' << g["b"].size(); ``
  2. 2. What does this print? ``cpp std::map<std::string, std::vector<int>> g; g["Pune"].push_back(1); std::cout << g.count("Goa") << ' ' << g.size() << ' '; std::cout << g["Goa"].size() << ' ' << g.size(); ``
  3. 3. A program groups orders by city like this, where Order is the struct from the lesson. ``cpp std::map<std::string, Order> byCity; for (const Order& o : orders) { byCity[o.city] = o; } `` Two orders are for Pune. What goes wrong?
  4. 4. Which method of std::multimap returns a pair of iterators that cover every entry for one key? Write its name only.

    Type your answer.

  5. 5. Which std::map method throws std::out_of_range when the key is missing? Write its name only.

    Type your answer.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.