Pergunta de entrevista da empresa Safran

They asked me to explain the difference between ArrayList and LinkedList in Java and their use cases.

Resposta da entrevista

Sigiloso

25 de set. de 2025

I explained that ArrayList is backed by a dynamic array, so it provides faster access (O(1)) for retrieval but slower insertions/removals in the middle. LinkedList, on the other hand, is implemented as a doubly linked list, making insertions and deletions faster (O(1)) when you already have the reference node, but access is slower (O(n)). I also gave examples of when each would be more suitable.