In the java solution we have:
Map<String, Integer> keywordsToCover = new HashMap<>();
for (String keyword : keywords) {
keywordsToCover.put(keyword,
keywordsToCover.containsKey(keyword)
? keywordsToCover.get(keyword) + 1
: 1);
}
why not just have this as the for loop?
Map<String, Integer> keywordsToCover = new HashMap<>();
for (String keyword : keywords) {
keywordsToCover.put(keyword, 1);
}