is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
Option 1) HashMap
- Anonymous March 24, 2013Instant response O(1) for looking for phone book entries, with 1000 entries there is very little chance of key collision.
But it's pretty sucky for the other two functions, requiring O(N*log(N)) roughly (grab the set of keys and sort, then return, also needs O(N) extra space).
Adding items is O(1) as well.
Option 2) Trie
Looking up items is O(c), where c is the number of characters.
Getting the sorted items is O(N) (just traverse trie), and grabbing items matching input keys is O(N) as well. Inserting is O(c) where c is the number of characters in the name/phone number.
Out of those I think the trie is probably the best option; retrieval of a particular number/name should still be very fast (since the names / numbers won't be too long) and the other two features will be very fast, and it's optimal in terms of space.