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

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 10 Jun 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 17 Jan 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.