Why Partially Correct


#1

HashMap<Integer, Integer> hm = new HashMap<>();
HashSet hs = new HashSet<>();
for(int i = 0; i < A.size(); i++)
{
hm.put(A.get(i), 1);
}
for(int i = 0; i < B.size(); i++)
{
if(hm.containsKey(B.get(i)) && hm.get(B.get(i)) == 2) hs.add(B.get(i));
else
{
hm.put(B.get(i), hm.getOrDefault(B.get(i), 0) + 1);
if(hm.get(B.get(i)) > 1) hs.add(B.get(i));
}
}
for(int i = 0; i < C.size(); i++)
{
if(hm.containsKey(C.get(i))) hs.add(C.get(i));
}
ArrayList ans = new ArrayList<>(hs);
Collections.sort(ans);
return ans;