Hi, let me tell you quickly the difference between hash table, linked list, and array data structure.
LL: Non-contiguous in memory, each node has data item and pointer to next. Good performance for iterate, O(n) performance for specific look up, O(n) for search.
Array: Contiguous in memory, no node just data item. Good performance for iterate, O(1) performance for specific look up, O(n) for search.
Hash table: Uses hash function to map a key (input) to a location (data), can't iterate but O(1) performance for specific look up and more importantly O(1) performance for searching. No key = can't search.
Edit: so i think its not appropriate to use hash table here. but good useful code anyways thanks for that.
Edit 2: usually you should use array because it is more efficient for memory. the only problem with array vs linkedlist is that insert a new element into the middle of array is slow, because you have to move all the shit in front of it. linkedlist you just need to add new node in memory, copy pointer of n-1 node into your new node and location of your new node into n-1 ptr. in java you dont get to use pointers though so idk, sry cant help there.