Determine the Edit Distance in a Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the minimum number of operations needed to change beginWord into endWord.
You can change only one letter at a time, and each intermediate word must exist in the word list. If there is no possible transformation, return None (Python), -1 (Java & C++), null (Javascript).
1Example 1
The transformation sequence can be: hit -> hot -> dot -> dog -> cog, which is 4 steps long.
2Example 2
Since the beginWord is the same as the endWord, no transformation is needed, so the number of steps is 0.
3Example 3
The word cog is not in the list, so there is no possible transformation sequence.