Kotlinlearncs.online LogoJava
Return to List

Homework: Map Has Duplicate Values

Created By: Geoffrey Challen
/ Version: 2021.9.0

Write a method hasDuplicateValues that, given a non-null Map<String, String>, returns true if the map contains duplicate values—meaning that two different keys map to the same value—and false otherwise. Recall that a map can never contain duplicate keys, since the second mapping from the same key overwrites the first.

You should use a Set to solve this problem! You do not need to import Map, Set, or HashSet, since these are already provided for you.

Related Lessons

Stuck? You may find these lessons helpful: