Well I started with that too but the interviewer eventually gave me answer in order of 3 and 4. I have told him that string copying (append operation) will make it n2. Then he went into details about what will happen during memory allocation. What will the graph look like when you are just about to throw OOME. And he said that it will lead to n3 or n4. I have read some many algorithm and O(n) and have never seen anyone talking about memory allocation and including that in your complexity calculation...