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.
Here is an idea - construct a prefix tree, where each node is character, child of a node exists if and only if there is a word in original collection that has these characters going one after another. E.g. for collection ['bar', 'baz', 'cat'], the tree would look like:
Now for each word in the collection, and for every rotation you can descend in the tree. If path exists - the rotation exists too. Note - it is also important to mark last symbol of a string as "terminal" in the tree, so that algorithm would not match "AB", "BCZ" as ["AB", BC'] -> C is not terminal.
Here is the full implementation in JS:
Tree is constructed in O(m) time, where `m` is total number of characters in your collection. The lookup for rotation is also linear function of characters count, so the overall performance is `O(m)`, `m` - total number of characters, and a constant factor of rotation counts (length of your alphabet).
- anvaka May 01, 2018