Interview practice question
Building a large string in a loop is slow
Backend Engineering · Language Runtimes · Beginner
Code that builds a CSV export by concatenating strings in a loop becomes very slow for large exports. Why, and what should you do?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Immutable strings: each concat copies.
- O(n²) behaviour.
- Use StringBuilder / join / buffers.
- Better: stream output directly.
- Use CSV library.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.