3 ms·
That's a setup for something that used to be a common interview question: how to extend a dynamic string or vector when you need to grow the allocation. If you
by not2b 6y ago
That's a setup for something that used to be a common interview question: how to extend a dynamic string or vector when you need to grow the allocation. If you allocate a fixed amount of excess (say, 5 bytes) when you need to grow the string, then repeatedly appending to your string or vector has quadratic cost. And an early version of Microsoft Foundation Classes (pre-STL, from the 80s) had this bug in the string class.