Could anyone help me with understanding why the 4th requirement is failing? I think I'm checking for it and should be good.
package com.codegym.task.task08.task0817;
import java.util.*;
import java.util.Map;
/*
We don't need repeats
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String, String> map = new HashMap<String, String>();
map.put("lol", "dood");
map.put("lola", "dood");
map.put("lolb", "dood");
map.put("lolc", "doocd");
map.put("lold", "doo8888d");
map.put("lole", "dosdod");
map.put("lolf", "doasfdod");
map.put("lolg", "daooda");
map.put("lolt", "dooad");
map.put("lolh", "dosod");
return map;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//write your code here
for (Map.Entry<String, String> pair : map.entrySet()) {
String fName = pair.getValue();
if (Collections.frequency(map.values(), fName) > 1) {
removeItemFromMapByValue(map, fName);
}
}
}
public static void removeItemFromMapByValue(Map<String, String> map, String value) {
HashMap<String, String> copy = new HashMap<String, String>(map);
for (Map.Entry<String, String> pair : copy.entrySet()) {
if (pair.getValue().equals(value))
map.remove(pair.getKey());
}
}
public static void main(String[] args) {
}
}