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
Press Submit to check your solution.
Back to lesson: Practice: Practice: Counting Allocations