Bloomberg | Phone | Word Ladder

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2020-06-16Added By Anonymous
Source: Link
Company: Bloomberg
Role: unknown
Stage: Phone
Location: unknown
Year: unknown

Original Experience:
You are given 2 strings and a dictionary of words, you need to tell the minimum steps in which you can convert string1 to string2, condition being you can change only one character in the string and the new string should be present in the given dictionary.

Example :
string1 = "ABBK"
string2 = "DBCN"
dictionary = {"DBPN", "ABPN", "ABKK", "ABPN", "DCCN", "ABPK" }

Answer = 4
{ABBK -> ABPK -> ABPN -> DBPN -> DBCN } -> total 4 conversions required.

Note that each string has only one character different from the previous one, also there can be multiple ways of converting string1 to string2, you need to output the one with minimum steps of conversion.
Comments