Do you know a solution to the following interview question?
Design a data structure for a phone book that can safely and efficiently search a number
Isn't this easy?
Using an array of record/struct/tuple of the value pair (telephone-number, name).
Do a linear search looking for the search key; O(n/2) for match, O(n) for miss,
return record/struct/tuple and do whatever needs to be done.
Edit:
This algorithm can be improved in many ways.
I think this interview question might be deliberately under specified in order to find out how the interviewee reacts. (That is what I do when I interview). So it may be more important to treat it as such, rather than assume it is just a Computer Science question.
I think it is worth engaging with the interviewer. For example:
etc.
I think it is more important to engage with the interviewer, rather than only focusing on the technical solution. When I interview, I am looking for someone who tries to actually understand the whole problem rather than the (usually small) part which is easy to define.