MCPcopy Index your code
hub / github.com/careercup/ctci / getOneEditWords

Method getOneEditWords

java/Chapter 18/Question18_10/Question.java:54–68  ·  view source on GitHub ↗
(String word)

Source from the content-addressed store, hash-verified

52 }
53
54 private static Set<String> getOneEditWords(String word) {
55 Set<String> words = new TreeSet<String>();
56 // for every letter
57 for (int i = 0; i < word.length(); i++) {
58 char[] wordArray = word.toCharArray();
59 // change that letter to something else
60 for (char c = 'A'; c <= 'Z'; c++) {
61 if (c != word.charAt(i)) {
62 wordArray[i] = c;
63 words.add(new String(wordArray));
64 }
65 }
66 }
67 return words;
68 }
69
70 public static HashSet<String> setupDictionary(String[] words) {
71 HashSet<String> hash = new HashSet<String>();

Callers 1

transformMethod · 0.95

Calls 2

lengthMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected