Lesson 10 of 24
vector: The Growable Array
9 min 30 XP
The STL (Standard Template Library) is C++'s superpower. A vector is an array that grows: push_back adds, size() counts, v[i] or v.at(i) reads. Competitive programmers use vectors everywhere.
Example: edit me and press Run
Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.v.at(i) checks bounds and throws an exception; v[i] doesn't check but is faster.