|
4 | 4 | importjava.util.List;
|
5 | 5 | importjava.util.Set;
|
6 | 6 |
|
7 |
| -/** |
8 |
| - * 127. Word Ladder |
9 |
| - * |
10 |
| - * Given two words (beginWord and endWord), and a dictionary's word list, |
11 |
| - * find the length of shortest transformation sequence from beginWord to endWord, such that: |
12 |
| - * Only one letter can be changed at a time. |
13 |
| - * Each transformed word must exist in the word list. Note that beginWord is not a transformed word. |
14 |
| -
|
15 |
| - For example, |
16 |
| -
|
17 |
| - Given: |
18 |
| - beginWord = "hit" |
19 |
| - endWord = "cog" |
20 |
| - wordList = ["hot","dot","dog","lot","log","cog"] |
21 |
| -
|
22 |
| - As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", return its length 5. |
23 |
| -
|
24 |
| - Note: |
25 |
| -
|
26 |
| - Return 0 if there is no such transformation sequence. |
27 |
| - All words have the same length. |
28 |
| - All words contain only lowercase alphabetic characters. |
29 |
| - You may assume no duplicates in the word list. |
30 |
| - You may assume beginWord and endWord are non-empty and are not the same. |
31 |
| - */ |
32 |
| - |
33 | 7 | publicclass_127 {
|
34 | 8 | publicstaticclassSolution1 {
|
35 | 9 |
|
|