We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Containers, Strings, Algorithms
C++Use standard containers, strings and algorithms. Reason about growth, lookup costs and reference invalidation when choosing and modifying collections.
This track uses C++. You can make it your practice mode to browse related content across the site.
5 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Reserve space before filling a vector Practice · Easy
- 2 Not solved yet. Reading text you do not own Practice · Medium
- 3 Not solved yet. The lookup that writes Practice · Medium
- 4 Not solved yet. Summarize a range with standard algorithms Practice · Medium
- 5 Not solved yet. Erasing while you walk Practice · Medium
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
What sizes and elements do a and b have after these operations succeed?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
#include <iostream>
#include <vector>
int main() {
std::vector<int> a;
a.reserve(5);
std::vector<int> b;
b.resize(5);
std::cout << a.size() << ' ' << b.size() << std::endl;
std::cout << std::boolalpha << (a.capacity() >= 5) << std::endl;
for (int x : b) std::cout << x;
std::cout << std::endl;
}