time complexity of list.get
Java List Time Complexity - Big O notation
1. add() – takes O(1) time. However, worst-case scenario,
when a new array has to be created and all the elements copied to it, is O(n).
2. add(index, element) – in average runs in O(n) time
3. get() – is always a constant time O(1) operation
4. remove() – runs in linear O(n) time. We have to iterate the entire array
to find the element qualifying for removal
5. indexOf() – also runs in linear time. It iterates through the internal
array and checking each element one by one. So the time
complexity for this operation always requires O(n) time
6. contains() – implementation is based on indexOf().
So it will also run in O(n) time