private static HashSet<String> transformOneLetter(String word, HashSet<String> dictionary) {
        HashSet<String> result = new HashSet<String>();
        for (int i = 0; i < word.length(); ++i) {
            StringBuilder sb = new StringBuilder(word);
            for (char letter = 'a'; letter <= 'z'; ++letter) {
                if (sb.charAt(i) != letter) {
                    sb.setCharAt(i, letter);
                    String newWord = sb.toString();
                    if (dictionary.contains(newWord)) {
                        result.add(newWord);
                    }
                }
            }
        }
        return result;
    }