Amazon interview question

Implement a reverse hash table

Interview Answers

Anonymous

Jul 30, 2013

As a way to make it as space-conserving as possible, the key->value pair can be inserted at the hashes of both the key and value. This would allow you to both differentiate a forward and reverse lookup, and use only a single additional pointer of space per entry.

1

Anonymous

Apr 2, 2013

This was easy enough but I somehow had seen this done with just one hash table and that isn't really possible. Should have gone with the simple, direct approach and optimized later.

Anonymous

Jul 12, 2013

Can you be more precise regarding the meaning of a "reverse hash table"

Anonymous

Jul 17, 2013

Say its a table T like this: T[1] = "Bob" T[2] = "Sally" T[3] = "Greg" Then it should also be possible to do: T["Bob"] = 1 T["Sally"] = 2 T["Greg"] = 3 Keys can be values and values can be used as keys