2
public String[] spellchecker(String[] wordlist, String[] queries) {3
String[] ans = new String[queries.length];4
Map<String, String>[] map = new HashMap[3];5
Arrays.setAll(map, o -> new HashMap<>());6
String pattern = "[aeiou]";8
for (String w : wordlist) {9
String lo = w.toLowerCase();11
map[1].putIfAbsent(lo, w);12
map[2].putIfAbsent(lo.replaceAll(pattern, "."), map[1].getOrDefault(w, w));16
for (String q : queries) {17
String lo = q.toLowerCase();18
String re = lo.replaceAll(pattern, ".");19
if (map[0].containsKey(q)) {21
} else if (map[1].containsKey(lo)) {22
ans[i] = map[1].get(lo);23
} else if (map[2].containsKey(re)) {24
ans[i] = map[2].get(re);