If I understood correctly, as soon as a person shares the same first name with a 2nd person, then we remove them from the map. And my code does that, however it fails validation: " The removeFirstNameDuplicates() method must remove from the map all people who have the same first name. " Thanks in advance! public class Solution { public static HashMap<String, String> createMap() { //write your code here HashMap<String, String> map = new HashMap<>(); map.put("Bogdan", "Vadim"); map.put("Tudor", "Vadim"); map.put("Dumitru", "Vasile"); map.put("Ioan", "Badea"); map.put("Petrica", "Badea"); map.put("Stanca", "Tudor"); map.put("Mazilu", "Toader"); map.put("Carmen", "Hara"); map.put("Body", "Vadim"); map.put("Vasile", "Vadim"); return map; } public static void removeFirstNameDuplicates(Map<String, String> map) { //write your code here ArrayList<String> firstNames = new ArrayList<>(map.values()); ArrayList<String> repeatedNames = new ArrayList<>(); for (int i = 0; i < firstNames.size(); i++) { for (int j = 0; j < firstNames.size(); j++) { if (firstNames.get(i).equals(firstNames.get(j)) && i != j){ repeatedNames.add(firstNames.get(i)); } } } for (int i = 0; i < repeatedNames.size() ; i++) { removeItemFromMapByValue(map, repeatedNames.get(i)); } } public static void removeItemFromMapByValue(Map<String, String> map, String value) { boolean isIn = false; for (Map.Entry<String, String> pair: map.entrySet()){ if (pair.getValue().equals(value)){ isIn = true; } } if(isIn) { Iterator<String> iterator = map.keySet().iterator(); while (iterator.hasNext()) { String s = iterator.next(); if (map.get(s).contains(value)) { iterator.remove(); } } } } public static void main(String[] args) { HashMap<String, String> map = createMap(); for (Map.Entry<String, String> pair: map.entrySet()){ System.out.println(pair.getKey() + " " + pair.getValue()); } removeFirstNameDuplicates(map); System.out.println("-----------------------------------------------------------------"); for (Map.Entry<String, String> pair: map.entrySet()){ System.out.println(pair.getKey() + " " + pair.getValue()); } }