Word Ladder
Try to solve the Word Ladder problem.
We'll cover the following
Statement
Given two words, src
and dest
, and a list, words
, return the number of words in the shortest transformation sequence from src
to dest
. If no such sequence can be formed, return .
A transformation sequence is a sequence of words src
that has the following properties:
-
dest
- Every pair of consecutive words differs by a single character.
- All the words in the sequence are present in the
words
. Thesrc
does not need to be present inwords
.
Constraints:
-
src.length
-
src.length
dest.length
words[i].length
-
src
dest
-
words.length
-
No duplicates in the
words
-
src
,dest
, andwords[i]
consist of lowercase English characters.
Examples
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy