Skip to main content

Practice Ā· 1 of 1

Reserve Then Build

Implement squares so it produces n values 1..n into the output vector using **at most one allocation**: reserve the exact capacity before writing. push_back in a loop after reserving is fine.

Difficulty: advanced

Back to lesson: Practice: Practice: Counting Allocations