3
Map<String, Integer> encryptedDictCount;5
Set<String> dictionary;8
public Encrypter(char[] keys, String[] values, String[] dictionary) {9
this.keys = new int[26];10
encryptedDictCount = new HashMap<>();11
this.val = values.clone();12
this.dictionary = new HashSet<>(Arrays.asList(dictionary));14
for (int i = 0; i < keys.length; i++) {15
this.keys[keys[i] - 'a'] = i;18
for (String dict : dictionary) {19
String encrpted = encrypt(dict);20
encryptedDictCount.put(encrpted, encryptedDictCount.getOrDefault(encrpted, 0) + 1);24
public String encrypt(String word1) {25
StringBuilder sb = new StringBuilder();26
for (int i = 0; i < word1.length(); i++) {27
int c = word1.charAt(i) - 'a';28
sb.append(val[keys[c]]);33
public int decrypt(String word2) {34
return encryptedDictCount.getOrDefault(word2, 0);