← Questions

Optimize a small-string class in C++

0
NvidiaCodingLast asked Dec 2025

Build a high-performance C++ string class for a workload with very many strings, supporting operations such as compare, concatenate and substring. Short strings live in a fixed-size buffer inside the object and longer ones on the heap (small-string optimization). Start with the constructor, then the copy and move operations and the destructor, and explain how each operation avoids allocations.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding