@@ -0,0 +1,1536 @@
+/**%0A * Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, %0A * such that only one letter can be changed at a time and each intermediate word must exist in the dictionary. For example, given: %0A * start = %22hit%22%0A * end = %22cog%22%0A * dict = %5B%22hot%22,%22dot%22,%22dog%22,%22lot%22,%22log%22%5D%0A * One shortest transformation is %22hit%22 -%3E %22hot%22 -%3E %22dot%22 -%3E %22dog%22 -%3E %22cog%22, the program should return its length 5.%0A * @author Jun%0A */%0A %0Apublic class Solution %7B%0A    public int ladderLength(String beginWord, String endWord, Set%3CString%3E wordList) %7B%0A        LinkedList%3CWordNode%3E queue = new LinkedList%3CWordNode%3E();%0A%09%09queue.add(new WordNode(beginWord, 1));%0A%09%09wordList.add(endWord);%0A%09%09%0A%09%09while(!queue.isEmpty()) %7B%0A%09%09%09WordNode top = queue.remove();%0A%09%09%09String topword = top.word;%0A%09%09%09if(topword.equals(endWord))%0A%09%09%09%09return top.depth;%09%0A%09%09%09// push all word in wordList having 1 letter different from topword%0A%09%09%09char%5B%5D array = topword.toCharArray();%0A%09%09%09for(int i = 0; i %3C array.length; i++) %7B%0A%09%09%09%09char tmp = array%5Bi%5D;%0A%09%09%09%09for(char c = 'a'; c %3C= 'z'; c++) %7B%0A%09%09%09%09%09if(array%5Bi%5D != c) array%5Bi%5D = c; // exclude the case where array == topword%0A%09%09%09%09%09String newWord = new String(array);%0A%09%09%09%09%09if (wordList.contains(newWord)) %7B%0A%09%09%09%09%09%09queue.add(new WordNode(newWord, top.depth+1));%0A%09%09%09%09%09%09wordList.remove(newWord);%0A%09%09%09%09%09%7D%0A%09%09%09%09%09array%5Bi%5D = tmp;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return 0;%0A    %7D%0A%09%0A%09private class WordNode %7B%0A%09%09String word;%0A%09%09int depth;%0A%09%09%0A%09%09WordNode(String word, int depth) %7B%0A%09%09this.word = word;%0A%09%09this.depth = depth;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create 127.java