Given a start word, an end word, and a dictionary of words, return the minimum number of single-letter changes needed to transform start into end where every intermediate word must appear in the dictionary. Return 0 if no such transformation exists.
Input
start: starting word
end: target word
wordList: array of allowed words
Output
Minimum number of transformation steps, or 0 if impossible.
Examples
Example 1
Inputstart = "COLD", end = "WARM", wordList = ["COLD", "GOLD", "CORD", "SOLD", "CARD", "WARD", "WARM", "TARD"]
Output0
Example 2
Inputstart = "a", end = "a", wordList = []
Output0
Constraints
All words have equal length and contain only the same character set.
Use BFS over the implicit graph where edges connect words differing by one letter.