127. Word LadderHard
A transformation sequence from word
beginWord
to wordendWord
using a dictionarywordList
is a sequence of wordsbeginWord -> s
1
-> s
2
-> ... -> sk
such that:
- Every adjacent pair of words differs by a single letter.
- Every
s
i
for1 <= i <= k
is in wordList. Note thatbeginWord
does not need to be inwordList
.s
k
== endWord
Given two words,
beginWord
andendWord
, and a dictionarywordList
, return the number of words in the shortest transformation sequence frombeginWord
toendWord
, or0
if no such sequence exists.
- Problem
- Solutions