Junior — Middle
What is the worst-case time complexity of adding elements to a dynamic array?
sobes.tech AI
Answer from AI
In the worst case, adding an element to a dynamic array has a time complexity of O(n). This occurs when the internal buffer of the array is full, and a new larger array needs to be allocated and all existing elements copied into it before adding the new one.