Given two words (start
), and a dictionary, find the shortest transformation sequence from start
, such that:
- Only one letter can be changed at a time
- Each intermediate word must exist in the dictionary
If there are multiple such sequences of the shortest length, return all of them.
Refer to the example for more details.Note
- All words have the same length.
- All words contain only lowercase alphabetic characters.
The first argument is string start.Output Format
The second argument is string end.
The third argument is an array of strings dict
Return all transformation sequences such that first word of each sequence is start and last word is end, all intermediate words belongs to dictionary(dict) and consecutive words had atmost 1 difference.Example Input
start = "hit"
end = "cog"
dict = ["hot","dot","dog","lot","log"]<>/pre
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified.
Still have a question? Checkout Sample Codes for more details.