@@ -0,0 +1,2181 @@
+package com.flang.bfs;%0A%0Aimport java.util.*;%0A%0A/**%0A * LC hard 127%0A *      1. Put wordlist into Hashset to clean duplicate word%0A *      2. Use BFS%EF%BC%8Ccreate Queue and HashSet for visited word%0A *      3. Ladder includes beginWord%EF%BC%8Cstep initial to 1%0A *      4. Loop queue%0A *      5. Modify each character in the word to get nextWord, if nextWord is in the wordlist and equals  to the endword, return step+1.%0A *      6. If nextWord is in the wordlist and but is not visited, add it to the queue and mark it as visited%0A *      7. Reset the word to origin after each word%E2%80%99s looping%0A *      8. Increase step on each BFS layer%0A *      9. Return 0 if not find the endword%0A */%0Apublic class WordLadder %7B%0A%0A    public int ladderLength(String beginWord, String endWord, List%3CString%3E wordList) %7B%0A        if(!wordList.contains(endWord)) return 0;%0A        int step = 1;%0A        Set%3CString%3E wordSet = new HashSet(wordList);%0A        Queue%3CString%3E queue = new LinkedList();%0A        Set%3CString%3E visited = new HashSet();%0A        queue.offer(beginWord);%0A%0A        while(!queue.isEmpty()) %7B%0A            int size = queue.size();%0A            for (int i = 0; i %3C size; i++) %7B%0A                String word = queue.poll();%0A                int len = word.length();%0A                char%5B%5D charArray = word.toCharArray();%0A                for (int j = 0; j %3C len; j++) %7B%0A                    char origin = charArray%5Bj%5D;%0A                    for (char c = 'a'; c %3C= 'z'; c++) %7B%0A                        if (c == charArray%5Bj%5D) continue;%0A                        charArray%5Bj%5D = c;%0A                        String nextWord = String.valueOf(charArray);%0A                        if (wordSet.contains(nextWord)) %7B%0A                            if (nextWord.equals(endWord)) %7B%0A                                return step + 1;%0A                            %7D%0A                            if (!visited.contains(nextWord)) %7B%0A                                queue.offer(nextWord);%0A                                visited.add(nextWord);%0A                            %7D%0A                        %7D%0A                    %7D%0A                    charArray%5Bj%5D = origin;%0A                %7D%0A            %7D%0A            step++;%0A        %7D%0A        return 0;%0A    %7D%0A%7D%0A

Create WordLadder.java