Shortest Transformation Sequence
Hard
Given two words, start and end, and a dictionary containing an array of words, return the length of the shortest transformation sequence to transform start to end. A transformation sequence is a series of words in which:
- Each word differs from the preceding word by exactly one letter.
- Each word in the sequence exists in the dictionary.
If no such transformation sequence exists, return 0.
Example:
Input: start = 'red', end = 'hit',
dictionary = [
'red', 'bed', 'hat', 'rod', 'rad', 'rat', 'hit', 'bad', 'bat'
]
Output: 5
Constraints:
- All words are the same length.
- All words contain only lowercase English letters.
- The dictionary contains no duplicate words.