@@ -0,0 +1,2703 @@
+class LeetCode0126 %7B%0A    class WordNode %7B%0A        String word;%0A        int numSteps;%0A        WordNode pre;%0A%0A        public WordNode(String word, int numSteps, WordNode pre) %7B%0A            this.word = word;%0A            this.numSteps = numSteps;%0A            this.pre = pre;%0A        %7D%0A    %7D%0A%0A    public List%3CList%3CString%3E%3E findLadders(String beginWord, String endWord, List%3CString%3E wordList) %7B%0A        List%3CList%3CString%3E%3E result = new ArrayList%3CList%3CString%3E%3E();%0A%0A        LinkedList%3CWordNode%3E queue = new LinkedList%3CWordNode%3E();%0A        queue.add(new WordNode(beginWord, 1, null));%0A%0A        int minStep = 0;%0A%0A        HashSet%3CString%3E visited = new HashSet%3CString%3E();%0A        HashSet%3CString%3E unvisited = new HashSet%3CString%3E();%0A        unvisited.addAll(wordList);%0A%0A        int preNumSteps = 0;%0A%0A        while (!queue.isEmpty()) %7B%0A            WordNode top = queue.remove();%0A            String word = top.word;%0A            int currNumSteps = top.numSteps;%0A%0A            if (word.equals(endWord)) %7B%0A                if (minStep == 0) %7B%0A                    minStep = top.numSteps;%0A                %7D%0A%0A                if (top.numSteps == minStep && minStep != 0) %7B%0A                    ArrayList%3CString%3E t = new ArrayList%3CString%3E();%0A                    t.add(top.word);%0A                    while (top.pre != null) %7B%0A                        t.add(0, top.pre.word);%0A                        top = top.pre;%0A                    %7D%0A                    result.add(t);%0A                    continue;%0A                %7D%0A%0A            %7D%0A%0A            if (preNumSteps %3C currNumSteps) %7B%0A                unvisited.removeAll(visited);%0A            %7D%0A%0A            preNumSteps = currNumSteps;%0A%0A            char%5B%5D arr = word.toCharArray();%0A            for (int i = 0; i %3C arr.length; i++) %7B%0A                for (char c = 'a'; c %3C= 'z'; c++) %7B%0A                    char temp = arr%5Bi%5D;%0A                    if (arr%5Bi%5D != c) %7B%0A                        arr%5Bi%5D = c;%0A                    %7D%0A%0A                    String newWord = new String(arr);%0A                    if (unvisited.contains(newWord)) %7B%0A                        queue.add(new WordNode(newWord, top.numSteps + 1, top));%0A                        visited.add(newWord);%0A                    %7D%0A%0A                    arr%5Bi%5D = temp;%0A                %7D%0A            %7D%0A%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LeetCode0126 leetcode = new LeetCode0126();%0A        List%3CString%3E wordList = new ArrayList%3CString%3E(Arrays.asList(%22hot%22, %22dog%22, %22dot%22));%0A        List%3CList%3CString%3E%3E result = leetcode.findLadders(%22hot%22, %22dog%22, wordList);%0A        for (int i = 0; i %3C result.size(); i++) %7B%0A            System.out.println((result.get(i).toString()));%0A        %7D%0A    %7D%0A%7D

Add LeetCode0126.java