Linkedin Interview Question
Country: United States
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.
There are two ways to approach the problem(code in C#) -
1.) One way BFS
a.) Create a class to store word and the level of the word from the root.
b.) Maintain a queue of the above class to do BFS.
c.) loop until queue is not empty
d.) For each char replace it with 26 possible chars and check if it exists in dictionary
e.) if found return the level.
2. Biderectional BFS -
a.) In previous solution as we go deeper , the number of words to loop will increase exponentially.
b.) if we consider end word as begin word , we could repeat the same step to find the soultion.
c.) Therefore , if we start from both end and eventually check if we found intermediate target list of words which can eventually form the end word in end list.
d.) Since we are using HashSet , We can save time for lopping through each word at deeper levels.
- agarwalanshul1987 May 22, 2016