It is basically an Interview question .
What is the best Data-Structure to be employed to store phone-numbers/Contact names in a phone directory . We should be able to retrieve number from name and vice-versa.
Few solutions i've heard of :
1. Create 2 Hashmaps , one maps number to name,other name to number.
2. Create 2 Tries . Uses lesser memory than above.
What better can be done for it , Talking mainly about Space complexity .
I think using 2 tries is the best option, space comlexity wise. Because once you have a hash table, you'll have to handle collisions.