A balanced binary search tree has O (log n) "get" and "remove" operations. A hash table implements the same operations O (1) times. In Java, you can use TreeMapeither HashMapclasses. For example:
TreeMap<Integer, String> map = new TreeMap<>();
map.put(0, "hello");
map.put(1, "world");
map.remove(0);
, ArrayList. , "get" - O (1). , , , O (1) "". :
temp = list.remove(list.size()-1);
return list.set(index, temp);