Given words (beginword and Endword), and a dictionary ' s word list, find the length of shortest trans Formation sequence from Beginword to Endword, such that:
- Only one letter can is changed at a time.
- Each transformed word must exist in the word list. Note that Beginword was not a transformed word.
Note:
- Return 0 If there is no such transformation sequence.
- All words has the same length.
- All words contain only lowercase alphabetic characters.
- Assume no duplicates in the word list.
- Assume Beginword and Endword are non-empty and is not the same.
Example 1:
Input:beginword = "hit", Endword = "Cog", wordList = [' hot ', ' dot ', ' dog ', ' lot ', ' log ', ' cog ']output:5explanation:as one Shortest transformation is ' hit ', "Hot", "dot", "dog" and "cog", return its length 5.
Example 2:
Input:beginword = "hit" Endword = "cog" wordList = [' hot ', ' dot ', ' dog ', ' lot ', ' log ']output:0explanation:the Endword ' cog ' I s not in wordList, therefore no possible transformation.
Ah
(Java) Leetcode 127. Word ladder--Word Solitaire