private List<String> expand(String word, Set<String> wordList) {
        char[] chars = word.toCharArray();
        List<String> result = new ArrayList<String>();
        for (int i = 0; i < chars.length; ++i) {
            char old = chars[i];
            for (char ch = 'a'; ch <= 'z'; ++ch) {
                if (ch != old) {
                    chars[i] = ch;
                    String newWord = new String(chars);
                    if (wordList.contains(newWord)) {
                        result.add(newWord);
                    }
                }
            }
            chars[i] = old;
        }
        return result;
    }