2
public String mostCommonWord(String paragraph, String[] banned) {4
HashMap<String, Integer> hm = new HashMap<>();5
String[] words = paragraph.replaceAll("[!?',;.]", " ").toLowerCase().split("\\s+");6
for (int i = 0; i < words.length; i++) {7
if (hm.containsKey(words[i])) hm.replace(words[i], hm.get(words[i]), hm.get(words[i]) + 1);8
else hm.put(words[i], 1);11
for (int i = 0; i < banned.length; i++) if (hm.containsKey(banned[i])) hm.remove(banned[i]);13
return Collections.max(hm.entrySet(), Map.Entry.comparingByValue()).getKey();