0

I have a set of numbers where each number has a key (ex. {"key1":1, "key2":2}). All the keys are unique. What is the best data structure to store them such that I can search by a key and find the value of that key efficiently? (possibly in logN time)

Mateo
  • 83
  • 5
  • An associative array like you're using gives you O(1) lookup, so you're done. – ggorlen Jan 11 '20 at 06:08
  • The usual data structure is a hash table. Under reasonable assumptions, its performance is O(1) for all operations. – Gene Jan 11 '20 at 07:11

0 Answers0