In JavaScript, I need some data structure that can hold strings, and has a fast way to search if a string exists in it, and to insert a string in it.
I was planning to use an array, but I am currently using a dictionary where the key is the string and the value is just 'true' even through I don't use it.
I went with dictionary because I would think it would be something like an AVL
tree, where the insert, delete and add are all O(log(n))
time. And the array would have an insert, delete, and search of O(n)
time.
Is this right, or is there a better way?
Thanks