Salesforce Interview Question: Given a regular English dicti... | Glassdoor

Interview Question

Senior Member of Technical Staff Interview

Given a regular English dictionary, and a word to start

  with (e.g. "head"), you can only change one letter a time, but every change has to be a word in the dictionary (e.g. head -> heal) What is the quickest way to an end word (e.g. "tail")?
Answer

Interview Answer

2 Answers

0

head
heal
teal
teil
tail

Dave on Jun 10, 2015
0

Create a graph in which every node a word in the dictionary, the edges connect words that are one character apart, now find the shortest path from source to destination word.

Shortest Path on Jan 17, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.