package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/vowel-spellchecker/
 */
public class Problem966 {
    public String[] spellchecker(String[] wordlist, String[] queries) {
        String[] answer = new String[queries.length];
        // TODO
        return queries;
    }

    public static void main(String[] args) {
        Problem966 prob = new Problem966();
        System.out.println(Arrays.toString(prob.spellchecker(
            new String[]{"KiTe", "kite", "hare", "Hare"},
            new String[]{"kite", "Kite", "KiTe", "Hare", "HARE", "Hear", "hear", "keti", "keet", "keto"})));
        // ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
    }
}

@@ -29,22 +29,93 @@
 va.util.
-Arrays
+HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set
 ;%0A%0A/**%0A 
@@ -280,489 +280,1568 @@
     
+Set%3C
 String
-%5B%5D answer = new String%5Bqueries.length%5D;%0A        // TODO%0A        return queries;%0A
+%3E exact = new HashSet%3C%3E();%0A        Map%3CString, String%3E caseInsensitive = new HashMap%3C%3E();%0A        Map%3CString, String%3E ignoreVowel = new HashMap%3C%3E();%0A        for (String word : wordlist) %7B%0A            exact.add(word);%0A            String lower = word.toLowerCase();%0A  
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem966 prob = new Problem966();%0A        System.out.println(Arrays.toString(prob.spellchecker(%0A            new String%5B%5D%7B%22KiTe%22, %22kite%22, %22hare%22, %22Hare%22%7D,
+  if (!caseInsensitive.containsKey(lower)) %7B%0A                caseInsensitive.put(lower, word);%0A            %7D%0A            String changeVowel = changeVowel(lower);%0A            if (!ignoreVowel.containsKey(changeVowel)) %7B%0A                ignoreVowel.put(changeVowel, word);%0A            %7D%0A        %7D%0A        String%5B%5D answer = new String%5Bqueries.length%5D;%0A        for (int i = 0; i %3C queries.length; i++) %7B%0A            if (exact.contains(queries%5Bi%5D)) %7B%0A                answer%5Bi%5D = queries%5Bi%5D;%0A            %7D else if (caseInsensitive.containsKey(queries%5Bi%5D.toLowerCase())) %7B%0A                answer%5Bi%5D = caseInsensitive.get(queries%5Bi%5D.toLowerCase());%0A            %7D else if (ignoreVowel.containsKey(changeVowel(queries%5Bi%5D.toLowerCase()))) %7B%0A                answer%5Bi%5D = ignoreVowel.get(changeVowel(queries%5Bi%5D.toLowerCase()));%0A            %7D else %7B%0A                answer%5Bi%5D = %22%22;%0A            %7D
 %0A      
+  %7D%0A
       
-new String%5B%5D%7B%22kite%22, %22Kite%22, %22KiTe%22, %22Hare%22, %22HARE%22, %22Hear%22, %22hear%22, %22keti%22, %22keet%22, %22keto%22%7D)));%0A        // %5B%22kite%22,%22KiTe%22,%22KiTe%22,%22Hare%22,%22hare%22,%22%22,%22%22,%22KiTe%22,%22%22,%22KiTe%22%5D
+  return answer;%0A    %7D%0A%0A    private static String changeVowel(String s) %7B%0A        char%5B%5D chars = s.toCharArray();%0A        for (int i = 0; i %3C chars.length; i++) %7B%0A            if (chars%5Bi%5D == 'a' %7C%7C chars%5Bi%5D == 'e' %7C%7C chars%5Bi%5D == 'u' %7C%7C%0A                chars%5Bi%5D == 'i' %7C%7C chars%5Bi%5D == 'o') %7B%0A                chars%5Bi%5D = 'a';%0A            %7D%0A        %7D%0A        return new String(chars);
 %0A   

Solve problem 966