Amazon Interview Question
Software Engineer / DevelopersTeam: SDE
Country: India
Interview Type: In-Person
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.
use tries for constant lookup in the dictionary
- Anonymous February 07, 2012In precompute phase build up an undirected graph where there is an edge between words A and B if we can transform A to B (and vs) by changing only one character. The above trie structure provides pointers to graph nodes for fast lookup.
Now for queries, we build up a matrix A of size N x N where N is the # of words.
s.t. A[i][j] = 1 if we can transform a word 'i' to work 'j' by changing one character at a time.
To build this matrix we execute BFS from each node of the graph and mark all reachable nodes. BFS also gives us the smallest # of steps to transform the words hence the last question is also answered