So to my knowledge duplicates are not allowed in a Java set. Why then in this code snippet does the code seem to try to take account of duplicates?
public static Subarray findSmallestSubarrayCoveringSet(List<String> paragraph,Set<String> keywords) {
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 keywordsToCover.put(keyword,1) inside the for loop?