i think my code is correat
but it is not meet the third condition
plz help me
thank u a lot
package com.codegym.task.task08.task0817;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
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> fullname = new HashMap<>();
fullname.put("Taylorr","Andrea");
fullname.put("Markley","Phil");
fullname.put("Taylor","Rosanna");
fullname.put("Williamsr","Andrea");
fullname.put("Williams","Laverne");
fullname.put("Taylorq","Andrea");
fullname.put("Taylora","Dan");
fullname.put("Golovko","Steve");
fullname.put("Cuff","Michele");
fullname.put("Brady","Keith");
return fullname;
}
public static void removeFirstNameDuplicates(Map<String, String> map) {
//write your code here
ArrayList<String> listvalue = new ArrayList<>();
for (Map.Entry<String,String> pair : map.entrySet()){
String value = pair.getValue();
listvalue.add(value);
}
for (int i = 0 ; i < listvalue.size();i++)
{
String s = listvalue.get(i);
removeItemFromMapByValue(map,s);
}
}
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) {
}
}