Skip to main content
All Questions

Design a fast, growable Array<T> whose elements never change address once created, where at(index) creates a zero-initialised element on first access.

Unlock detailed company stats for this questionUpgrade
Design a fast, growable Array<T> class template. Once an element exists its address must never change until the array is destroyed. Storage need not be contiguous: elements may sit in separate blocks that are added as the array grows. T is zero-initialisable, meaning a block of zeroed memory is a valid T. Reading an index that does not exist yet must allocate it and zero-initialise it automatically, and random access by index must be fast. Implement T& at(size_t index), which creates the element if it is not there yet.

Community answers

No answers contributed by the community yet.

Related courses

Course

Behavioral Interviews: A Practical Guide for Engineers

Get offers at the level you deserve. Prep for senior+ behavioral interviews at FAANG and Tier-1 companies. Made with staff and principal engineers from Meta, Netflix, Google, and more. Avoid downleveling, elevate past projects, and stop sounding like a robot.

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.